|
@@ -1,5 +1,9 @@
|
|
|
package com.ym.mec.task.controller;
|
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -11,6 +15,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -25,6 +30,7 @@ import com.ym.mec.util.collection.MapUtil;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(value = "task")
|
|
|
+@Api(description = "任务调度")
|
|
|
public class TaskController extends BaseController {
|
|
|
|
|
|
private final static Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
|
|
@@ -35,7 +41,8 @@ public class TaskController extends BaseController {
|
|
|
@Autowired
|
|
|
private Scheduler scheduler;
|
|
|
|
|
|
- @GetMapping(value = "list")
|
|
|
+ @ApiOperation("任务列表分页查询")
|
|
|
+ @GetMapping("/list")
|
|
|
public HttpResponseResult list(TaskQueryInfo queryInfo) {
|
|
|
PageInfo<Task> pageInfo = new PageInfo<Task>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
@@ -55,8 +62,10 @@ public class TaskController extends BaseController {
|
|
|
return succeed(pageInfo);
|
|
|
}
|
|
|
|
|
|
- @PostMapping(value = "execute")
|
|
|
- public HttpResponseResult execute(int taskId) {
|
|
|
+ @ApiOperation("执行当前任务")
|
|
|
+ @ApiImplicitParam(name = "taskId", value = "任务编号", required = true, dataType = "Integer", paramType = "path")
|
|
|
+ @PostMapping("/execute/{taskId}")
|
|
|
+ public HttpResponseResult execute(@PathVariable("taskId") int taskId) {
|
|
|
boolean result = false;
|
|
|
try {
|
|
|
result = taskService.execute(taskId, scheduler);
|
|
@@ -67,8 +76,10 @@ public class TaskController extends BaseController {
|
|
|
return result ? succeed() : failed();
|
|
|
}
|
|
|
|
|
|
- @PostMapping(value = "pause")
|
|
|
- public HttpResponseResult pause(int taskId) {
|
|
|
+ @ApiOperation("暂停当前任务")
|
|
|
+ @ApiImplicitParam(name = "taskId", value = "任务编号", required = true, dataType = "Integer", paramType = "path")
|
|
|
+ @PostMapping("/pause/{taskId}")
|
|
|
+ public HttpResponseResult pause(@PathVariable("taskId") int taskId) {
|
|
|
boolean result = false;
|
|
|
try {
|
|
|
result = taskService.pause(taskId, scheduler);
|
|
@@ -79,8 +90,10 @@ public class TaskController extends BaseController {
|
|
|
return result ? succeed() : failed();
|
|
|
}
|
|
|
|
|
|
- @PostMapping(value = "resume")
|
|
|
- public HttpResponseResult resume(int taskId) {
|
|
|
+ @ApiOperation("暂停当前任务")
|
|
|
+ @ApiImplicitParam(name = "taskId", value = "任务编号", required = true, dataType = "Integer", paramType = "path")
|
|
|
+ @PostMapping("/resume/{taskId}")
|
|
|
+ public HttpResponseResult resume(@PathVariable("taskId") int taskId) {
|
|
|
boolean result = false;
|
|
|
try {
|
|
|
result = taskService.resume(taskId, scheduler);
|