|
|
@ -0,0 +1,50 @@ |
|
|
|
package com.iflytop.nuclear.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.iflytop.nuclear.model.Path; |
|
|
|
import com.iflytop.nuclear.model.Task; |
|
|
|
import com.iflytop.nuclear.service.PathService; |
|
|
|
import com.iflytop.nuclear.service.TaskService; |
|
|
|
import com.iflytop.nuclear.utils.ResponseData; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author cool |
|
|
|
* @date 2023/7/7 10:36 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@CrossOrigin |
|
|
|
@RequestMapping("/path") |
|
|
|
@PreAuthorize("hasRole('ADMIN')") |
|
|
|
public class PathController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
TaskService taskService; |
|
|
|
@Autowired |
|
|
|
PathService pathService; |
|
|
|
|
|
|
|
@GetMapping("/check/{id}") |
|
|
|
public ResponseData check(@PathVariable(name = "id") int taskId) { |
|
|
|
Task task = taskService.getById(taskId); |
|
|
|
int status = task.getStatus(); |
|
|
|
if (status != 0) { |
|
|
|
// 任务已经开始 |
|
|
|
return ResponseData.fail("当前任务已经在流程中,不可更改路径规划"); |
|
|
|
} |
|
|
|
return ResponseData.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/plan") |
|
|
|
public ResponseData plan(@RequestBody List<Path> pathList) { |
|
|
|
boolean b = pathService.plan(pathList); |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("result", b); |
|
|
|
return ResponseData.success(jsonObject); |
|
|
|
} |
|
|
|
} |