[ server ] - add quartz and knife4j framework
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package io.wdd.rpc.controller;
|
||||
|
||||
import io.wdd.common.beans.response.R;
|
||||
import io.wdd.rpc.execute.result.CreateStreamReader;
|
||||
import io.wdd.rpc.execute.service.CoreExecutionService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.COMMAND_RESULT_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("octopus/server/executor")
|
||||
public class ExecutionController {
|
||||
|
||||
@Resource
|
||||
CoreExecutionService coreExecutionService;
|
||||
|
||||
@Resource
|
||||
CreateStreamReader createStreamReader;
|
||||
|
||||
|
||||
@PostMapping("command")
|
||||
public R<String> patchCommandToAgent(
|
||||
@RequestParam(value = "topicName") String topicName,
|
||||
@RequestParam(value = "commandList", required = false) @Nullable List<String> commandList,
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
String streamKey = "";
|
||||
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
streamKey = coreExecutionService.SendCommandToAgent(topicName, commandList);
|
||||
} else {
|
||||
streamKey = coreExecutionService.SendCommandToAgent(topicName, type, commandList);
|
||||
}
|
||||
|
||||
return R.ok(streamKey);
|
||||
}
|
||||
|
||||
@PostMapping("/stream")
|
||||
public void GetCommandLog(
|
||||
@RequestParam(value = "streamKey") String streamKey
|
||||
) {
|
||||
|
||||
createStreamReader.registerStreamReader(COMMAND_RESULT_REDIS_STREAM_LISTENER_CONTAINER ,streamKey);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/agentStatusStream")
|
||||
public void getAgentStatus(
|
||||
@RequestParam(value = "streamKey") String streamKey
|
||||
) {
|
||||
|
||||
createStreamReader.registerStreamReader(AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER ,streamKey);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/agentUpdate")
|
||||
public void AgentUpdate(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package io.wdd.rpc.controller;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.*;
|
||||
import io.wdd.rpc.scheduler.config.UpdateJobBean;
|
||||
import io.wdd.rpc.scheduler.service.OctopusQuartzService;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(value = "quartz增删改查相关API")
|
||||
@RequestMapping(value = "/quartz")
|
||||
public class QuartzCRUDController {
|
||||
|
||||
@Autowired
|
||||
OctopusQuartzService octopusQuartzService;
|
||||
|
||||
// @ApiOperation(value = "使用quartz添加job")
|
||||
// @RequestMapping(value = "/addJob/{jobUUID}", method = RequestMethod.POST)
|
||||
// public void addQuartzJob(@ApiParam(name = "jobUUID") @PathVariable("jobUUID") String jobUUID, @ApiParam(name = "JobXXXBean") @RequestBody JobXXXBean jobXXXBean) {
|
||||
//
|
||||
// if (jobXXXBean.getOpenBean() != null) {
|
||||
// JobDataMap jobDataMap = new JobDataMap();
|
||||
// jobDataMap.put("key01", jobXXXBean.getKey01());
|
||||
// jobDataMap.put("key02", jobXXXBean.getKey02());
|
||||
// jobDataMap.put("key03", jobXXXBean.getKey03());
|
||||
// jobDataMap.put("jobTimeCron", jobXXXBean.getJobTimeCron());
|
||||
// jobDataMap.put("key04", jobXXXBean.getKey04());
|
||||
// octopusQuartzService.addJob(Job1.class, jobUUID, jobUUID, jobXXXBean.getJobTimeCron(), jobDataMap);
|
||||
// } else {
|
||||
// throw new BadRequestException("参数错误");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@ApiOperation(value = "使用quartz查询所有job")
|
||||
@RequestMapping(value = "/queryAllJob", method = RequestMethod.GET)
|
||||
public List<Map<String, Object>> queryAllQuartzJob() {
|
||||
|
||||
List<Map<String, Object>> list = octopusQuartzService.queryAllJob();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "使用quartz查询所有运行job")
|
||||
@RequestMapping(value = "/queryRunJob", method = RequestMethod.GET)
|
||||
public List<Map<String, Object>> queryRunQuartzJob() {
|
||||
|
||||
List<Map<String, Object>> list = octopusQuartzService.queryRunJob();
|
||||
return list;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "使用quartz删除job")
|
||||
@RequestMapping(value = "/deleteJob/{jobUUID}", method = RequestMethod.DELETE)
|
||||
public void deleteJob(@ApiParam(name = "jobUUID") @PathVariable("jobUUID") String jobUUID) {
|
||||
|
||||
octopusQuartzService.deleteJob(jobUUID, jobUUID);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "使用quartz修改job的cron时间")
|
||||
@RequestMapping(value = "/updateJob/{jobUUID}", method = RequestMethod.PUT)
|
||||
public void deleteJob(@ApiParam(name = "jobUUID") @PathVariable("jobUUID") String jobUUID, @ApiParam(name = "jobCronTime") @RequestBody UpdateJobBean updateJobBean) {
|
||||
|
||||
octopusQuartzService.updateJob(jobUUID, jobUUID, updateJobBean.getJobCronTime());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user