1、当36壁纸爬虫正在执行时,不可修改配置

2、36壁纸新增接口权限验证
pull/254/head
xjs 4 years ago
parent 8638b4de30
commit add64ea618

@ -13,13 +13,13 @@
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px"> <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
<el-col :span="3"> <el-col :span="3">
<el-form-item label="下载图片" prop="downloadImg" required> <el-form-item label="下载图片" prop="downloadImg" required>
<el-switch v-model="formData.downloadImg" active-color="#3292CD" inactive-color="#D74747"> <el-switch v-model="formData.downloadImg" active-color="#3292CD" inactive-color="#D74747">
</el-switch> </el-switch>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
<el-form-item label="初始化爬取" prop="init" required> <el-form-item label="初始化爬取" prop="init" required>
<el-switch v-model="formData.init" active-color="#3292CD" inactive-color="#D74747"></el-switch> <el-switch v-model="formData.init" active-color="#3292CD" inactive-color="#D74747"></el-switch>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="7"> <el-col :span="7">
@ -30,9 +30,21 @@
</el-col> </el-col>
<el-col :span="9"> <el-col :span="9">
<el-form-item> <el-form-item>
<el-button size="mini" type="primary" @click="submitForm"></el-button> <el-button
size="mini"
type="primary"
@click="submitForm"
v-hasPermi="['webmagic:_36wallpaper:update']"
>提交
</el-button>
<el-button size="mini" @click="resetForm"></el-button> <el-button size="mini" @click="resetForm"></el-button>
<el-button size="mini" type="info" icon="el-icon-refresh" @click="resetSettings"></el-button> <el-button
size="mini"
type="info"
icon="el-icon-refresh"
@click="resetSettings"
v-hasPermi="['webmagic:_36wallpaper:update']"
>恢复默认</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form> </el-form>
@ -43,7 +55,7 @@
<script> <script>
import {getSettings,updateSettings,resetSettings} from '@/api/business/webmagic/_36wallpaper/wallpaper36' import {getSettings, updateSettings, resetSettings} from '@/api/business/webmagic/_36wallpaper/wallpaper36'
export default { export default {
name: "Wallpaper_36Settings", name: "Wallpaper_36Settings",
@ -84,7 +96,7 @@ export default {
// //
resetSettings() { resetSettings() {
resetSettings().then(res =>{ resetSettings().then(res => {
this.$modal.msgSuccess("重置成功"); this.$modal.msgSuccess("重置成功");
this.getSettings() this.getSettings()
}) })
@ -93,11 +105,11 @@ export default {
submitForm() { submitForm() {
this.$refs['elForm'].validate(valid => { this.$refs['elForm'].validate(valid => {
if (!valid) return if (!valid) return
let json ={ let json = {
json:null json: null
} }
json.json = JSON.stringify(this.formData); json.json = JSON.stringify(this.formData);
updateSettings(json).then(res =>{ updateSettings(json).then(res => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
}) })
}) })

@ -1,13 +1,86 @@
<template> <template>
<div>
<div class="bigDiv">
<el-row :gutter="20" class="el-row">
<el-col :span="4">
<div class="grid-content bg-purple">
</div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
</el-row>
<el-row :gutter="20" class="el-row">
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple"></div>
</el-col>
</el-row>
</div>
<!-- <pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>-->
</div>
</template> </template>
<script> <script>
export default { export default {
name: "_36wallpaperShow" name: "wallpaper_36Show"
} }
</script> </script>
<style scoped> <style scoped>
.bg-purple {
background: #d3dce6;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
max-height: 350px;
height: 320px;
}
.bigDiv{
margin: 15px;
}
.el-row{
margin-bottom: 15px;
}
</style> </style>

@ -3,6 +3,7 @@ package com.xjs._36wallpaper.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.xjs._36wallpaper.service._36wallpaperService; import com.xjs._36wallpaper.service._36wallpaperService;
import com.xjs._36wallpaper.task._36wallpaperTask; import com.xjs._36wallpaper.task._36wallpaperTask;
import com.xjs.web.MyBaseController; import com.xjs.web.MyBaseController;
@ -33,6 +34,7 @@ public class _36wallpaperController extends MyBaseController {
@GetMapping("getSettings") @GetMapping("getSettings")
@ApiOperation("获取参数配置") @ApiOperation("获取参数配置")
@RequiresPermissions("webmagic:_36wallpaper:list")
public AjaxResult getSettings() { public AjaxResult getSettings() {
JSONObject jsonObject = wallpaperService.getSettings(); JSONObject jsonObject = wallpaperService.getSettings();
if (Objects.nonNull(jsonObject)) { if (Objects.nonNull(jsonObject)) {
@ -44,6 +46,7 @@ public class _36wallpaperController extends MyBaseController {
@PutMapping("updateSettings") @PutMapping("updateSettings")
@ApiOperation("修改参数配置") @ApiOperation("修改参数配置")
@RequiresPermissions("webmagic:_36wallpaper:update")
public AjaxResult updateSettings(@RequestParam("json") String json) { public AjaxResult updateSettings(@RequestParam("json") String json) {
boolean b=wallpaperService.updateSettings(json); boolean b=wallpaperService.updateSettings(json);
return toAjax(b); return toAjax(b);
@ -51,6 +54,7 @@ public class _36wallpaperController extends MyBaseController {
@PutMapping("reset") @PutMapping("reset")
@ApiOperation("重置参数配置") @ApiOperation("重置参数配置")
@RequiresPermissions("webmagic:_36wallpaper:update")
public AjaxResult resetSettings() { public AjaxResult resetSettings() {
boolean b=wallpaperService.resetSettings(); boolean b=wallpaperService.resetSettings();
return toAjax(b); return toAjax(b);

@ -17,6 +17,7 @@ import javax.annotation.Resource;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.xjs._36wallpaper.consts._36wallpaperConst.*; import static com.xjs._36wallpaper.consts._36wallpaperConst.*;
import static com.xjs.consts.RedisConst.REPTILE_COUNT;
import static com.xjs.consts.RegexConst.FILE_PATH_REGEX; import static com.xjs.consts.RegexConst.FILE_PATH_REGEX;
/** /**
@ -74,6 +75,11 @@ public class _36wallpaperServiceImpl extends ServiceImpl<_36wallpaperMapper, _36
@Override @Override
public boolean updateSettings(String json) { public boolean updateSettings(String json) {
//判断爬虫是否正在执行,正在执行不可修改!
if(redisService.hasKey(REPTILE_COUNT)){
throw new BusinessException("爬虫正在执行中!暂时无法修改,请稍后再试");
}
//校验json格式是否正确 //校验json格式是否正确
try { try {
JSONObject jsonObject = JSONObject.parseObject(json); JSONObject jsonObject = JSONObject.parseObject(json);

@ -271,6 +271,11 @@ public class _36wallpaperProcessor implements PageProcessor {
* @return * @return
*/ */
public Long run() { public Long run() {
//创建下载器Downloader
//HttpClientDownloader downloader = new HttpClientDownloader();
//给下载器设置代理服务器
//downloader.setProxyProvider(SimpleProxyProvider.from(new Proxy("60.191.11.249",3128)));
//执行爬虫 //执行爬虫
Spider.create(new _36wallpaperProcessor()) Spider.create(new _36wallpaperProcessor())
.addUrl(_36_WALLPAPER_URL)//设置爬取地址 .addUrl(_36_WALLPAPER_URL)//设置爬取地址
@ -278,6 +283,7 @@ public class _36wallpaperProcessor implements PageProcessor {
.setScheduler(new QueueScheduler() .setScheduler(new QueueScheduler()
.setDuplicateRemover(new BloomFilterDuplicateRemover(110000)))//设置url去重过滤器 .setDuplicateRemover(new BloomFilterDuplicateRemover(110000)))//设置url去重过滤器
//.addPipeline(wallpaperPipeline)//设置爬取之后的数据操作 //.addPipeline(wallpaperPipeline)//设置爬取之后的数据操作
//.setDownloader(downloader)//设置下载器
.run();//执行 .run();//执行
//删除重复数据 //删除重复数据

Loading…
Cancel
Save