Merge pull request #33 from everydoc/master

add crawl copy
This commit is contained in:
nekolr 2022-06-06 09:03:55 +08:00 committed by GitHub
commit 445d404591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 37 deletions

View File

@ -137,6 +137,13 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
spiderJobManager.remove(id);
}
public void copy(String id){
// 复制ID
SpiderFlow spiderFlow = sfMapper.selectById(id);
String new_id = UUID.randomUUID().toString().replace("-", "");
sfMapper.insertSpiderFlow(new_id, spiderFlow.getName() + "-copy", spiderFlow.getXml());
}
public void start(String id){
spiderJobManager.remove(id);
SpiderFlow spiderFlow = getById(id);

View File

@ -148,6 +148,11 @@ public class SpiderFlowController {
spiderFlowService.stop(id);
}
@RequestMapping("/copy")
public void copy(String id){
spiderFlowService.copy(id);
}
@RequestMapping("/run")
public void run(String id){
spiderFlowService.run(id);

View File

@ -84,7 +84,7 @@
align : 'center'
},{
title : '操作',
width : 195,
width : 250,
align : 'center',
templet : '#buttons'
}]]
@ -121,6 +121,28 @@
}
$("body").on('click','.btn-search',function(){
reloadTable();
}).on('click','.btn-copy',function(){
var id = $(this).data('id');
layui.layer.confirm('您确定要复制此爬虫吗',{
title : '复制'
},function(index){
$table.reload();
$.ajax({
url : 'spider/copy',
data : {
id : id
},
success : function(){
layui.layer.msg('复制成功',{time : 500},function(){
$table.reload();
})
},
error : function(){
layui.layer.msg('复制失败')
}
})
layui.layer.close(index);
})
}).on('click','.btn-remove',function(){
var id = $(this).data('id');
layui.layer.confirm('您确定要删除此爬虫吗',{