mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-08-29 02:10:43 +08:00
爬虫模块 接口重构
This commit is contained in:
@@ -17,3 +17,4 @@
|
||||
/chopperbot-test/config/
|
||||
/chopperbot-test/database.db/
|
||||
/.idea/
|
||||
/database.db
|
||||
|
||||
@@ -87,5 +87,11 @@
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.969025903</groupId>
|
||||
<artifactId>assistant</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -62,12 +62,6 @@
|
||||
<artifactId>chopperbot-section-work</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.969025903</groupId>
|
||||
<artifactId>assistant</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package org.example.controller;
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.HotModuleApi;
|
||||
import org.example.bean.Live;
|
||||
import org.example.bean.MonitorVO;
|
||||
import org.example.bean.ReptileTaskVO;
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.core.HotModuleDataCenter;
|
||||
import org.example.core.manager.CreeperBean;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.example.service.CreeperService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/09/06 00:58
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/creeper")
|
||||
public class CreeperController {
|
||||
|
||||
@Resource
|
||||
CreeperService creeperService;
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_CENTER_PLUGIN})
|
||||
@GetMapping("/taskCenter/getAllTask")
|
||||
public Result getAllTaskCenter(){
|
||||
List<ReptileTaskVO> allTask = creeperService.taskCenterApi().getAllTask();
|
||||
return Result.success(Map.of(
|
||||
"list",allTask
|
||||
));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_CENTER_PLUGIN})
|
||||
@GetMapping("/taskCenter/stop")
|
||||
public Result stopTask(@RequestParam String taskId){
|
||||
boolean isStop = creeperService.taskCenterApi().stopRunningTask(taskId);
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"taskId",taskId,
|
||||
"stop", isStop
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.CREEPER_MANAGER_PLUGIN})
|
||||
@GetMapping("/creeperManager/getAllCreeper")
|
||||
public Result getAllCreeper(){
|
||||
List<CreeperBean> allCreeper = creeperService.creeperManagerApi().getAllCreeper();
|
||||
return Result.success(Map.of(
|
||||
"list",allCreeper
|
||||
));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_MONITOR_PLUGIN})
|
||||
@GetMapping("/monitor/all")
|
||||
public Result allMonitor(){
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"list",creeperService.monitorApi().getStartMonitor()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_MONITOR_PLUGIN})
|
||||
@GetMapping("/monitor/start")
|
||||
public Result startMonitor(@RequestParam String taskId){
|
||||
MonitorVO monitor = creeperService.monitorApi().hasMonitor(taskId);
|
||||
if(monitor==null){
|
||||
return Result.error("400", String.format("%s 不存在监视器", taskId));
|
||||
}else{
|
||||
return Result.success(
|
||||
Map.of("monitor",monitor)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_MONITOR_PLUGIN})
|
||||
@GetMapping("/monitor/stop")
|
||||
public Result stopMonitor(@RequestParam String taskId){
|
||||
boolean isStop = creeperService.monitorApi().stop(taskId);
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"taskId",taskId,
|
||||
"stop", isStop
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,6 @@ import java.util.List;
|
||||
**/
|
||||
@Component
|
||||
public class CreeperManagerApi {
|
||||
|
||||
|
||||
|
||||
public List<CreeperBean> getAllCreeper(){
|
||||
CreeperManager plugin = InitPluginRegister.getPlugin(PluginName.CREEPER_MANAGER_PLUGIN, CreeperManager.class);
|
||||
assert plugin != null;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.example.controller;
|
||||
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.CreeperManagerApi;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.core.manager.CreeperBean;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/creeper/creeperManager")
|
||||
public class CreeperManagerController {
|
||||
|
||||
@Resource
|
||||
private CreeperManagerApi creeperManagerApi;
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.CREEPER_MANAGER_PLUGIN})
|
||||
@GetMapping("/getAllCreeper")
|
||||
public Result getAllCreeper(){
|
||||
List<CreeperBean> allCreeper = creeperManagerApi.getAllCreeper();
|
||||
return Result.success(Map.of(
|
||||
"list",allCreeper
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.example.controller;
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.MonitorCenterApi;
|
||||
import org.example.bean.MonitorVO;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/creeper/monitor")
|
||||
public class MonitorController {
|
||||
|
||||
@Resource
|
||||
private MonitorCenterApi monitorCenterApi;
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_MONITOR_PLUGIN})
|
||||
@GetMapping("/all")
|
||||
public Result allMonitor(){
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"list",monitorCenterApi.getStartMonitor()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_MONITOR_PLUGIN})
|
||||
@GetMapping("/start")
|
||||
public Result startMonitor(@RequestParam String taskId){
|
||||
MonitorVO monitor = monitorCenterApi.hasMonitor(taskId);
|
||||
if(monitor==null){
|
||||
return Result.error("400", String.format("%s 不存在监视器", taskId));
|
||||
}else{
|
||||
return Result.success(
|
||||
Map.of("monitor",monitor)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_MONITOR_PLUGIN})
|
||||
@GetMapping("/stop")
|
||||
public Result stopMonitor(@RequestParam String taskId){
|
||||
boolean isStop = monitorCenterApi.stop(taskId);
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"taskId",taskId,
|
||||
"stop", isStop
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.example.controller;
|
||||
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.TaskCenterApi;
|
||||
import org.example.bean.ReptileTaskVO;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/creeper/taskCenter")
|
||||
public class TaskCenterController {
|
||||
|
||||
@Resource
|
||||
TaskCenterApi taskCenterApi;
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_CENTER_PLUGIN})
|
||||
@GetMapping("/getAllTask")
|
||||
public Result getAllTaskCenter(){
|
||||
List<ReptileTaskVO> allTask = taskCenterApi.getAllTask();
|
||||
return Result.success(Map.of(
|
||||
"list",allTask
|
||||
));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.TASK_CENTER_PLUGIN})
|
||||
@GetMapping("/stop")
|
||||
public Result stopTask(@RequestParam String taskId){
|
||||
boolean isStop = taskCenterApi.stopRunningTask(taskId);
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"taskId",taskId,
|
||||
"stop", isStop
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
-1
@@ -4,7 +4,6 @@ import org.example.api.CreeperManagerApi;
|
||||
import org.example.api.MonitorCenterApi;
|
||||
import org.example.api.TaskCenterApi;
|
||||
import org.example.service.CreeperService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
+1
-1
@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Plugin(moduleName = ModuleName.SECTION_WORK,
|
||||
pluginName = PluginName.DESC_GENERATE,
|
||||
pluginName_CN = "标题生成插件",
|
||||
pluginName_CN = "视频描述生成插件",
|
||||
pluginDescription = "根据切片内容自动生成切片标题",
|
||||
pluginClass= DescGeneratorPlugin.class,
|
||||
springBootPlugin = true,
|
||||
|
||||
@@ -6,3 +6,4 @@ export interface FollowDog{
|
||||
top:number;
|
||||
banLiver:string;
|
||||
}
|
||||
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user