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

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

@ -30,9 +30,21 @@
</el-col>
<el-col :span="9">
<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" 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-col>
</el-form>
@ -43,7 +55,7 @@
<script>
import {getSettings,updateSettings,resetSettings} from '@/api/business/webmagic/_36wallpaper/wallpaper36'
import {getSettings, updateSettings, resetSettings} from '@/api/business/webmagic/_36wallpaper/wallpaper36'
export default {
name: "Wallpaper_36Settings",
@ -84,7 +96,7 @@ export default {
//
resetSettings() {
resetSettings().then(res =>{
resetSettings().then(res => {
this.$modal.msgSuccess("重置成功");
this.getSettings()
})
@ -93,11 +105,11 @@ export default {
submitForm() {
this.$refs['elForm'].validate(valid => {
if (!valid) return
let json ={
json:null
let json = {
json: null
}
json.json = JSON.stringify(this.formData);
updateSettings(json).then(res =>{
updateSettings(json).then(res => {
this.$modal.msgSuccess("修改成功");
})
})

@ -1,13 +1,86 @@
<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>
<script>
export default {
name: "_36wallpaperShow"
name: "wallpaper_36Show"
}
</script>
<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>

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

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

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

Loading…
Cancel
Save