add crawl copy

This commit is contained in:
AlanTuring 2022-06-04 17:17:08 +08:00
parent a75b15484d
commit 8b4e49021d
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); 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){ public void start(String id){
spiderJobManager.remove(id); spiderJobManager.remove(id);
SpiderFlow spiderFlow = getById(id); SpiderFlow spiderFlow = getById(id);

View File

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

View File

@ -84,7 +84,7 @@
align : 'center' align : 'center'
},{ },{
title : '操作', title : '操作',
width : 195, width : 250,
align : 'center', align : 'center',
templet : '#buttons' templet : '#buttons'
}]] }]]
@ -121,6 +121,28 @@
} }
$("body").on('click','.btn-search',function(){ $("body").on('click','.btn-search',function(){
reloadTable(); 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(){ }).on('click','.btn-remove',function(){
var id = $(this).data('id'); var id = $(this).data('id');
layui.layer.confirm('您确定要删除此爬虫吗',{ layui.layer.confirm('您确定要删除此爬虫吗',{