核查系统api
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

2 years ago
  1. package com.iflytop.nuclear.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.iflytop.nuclear.model.Path;
  4. import com.iflytop.nuclear.model.Task;
  5. import com.iflytop.nuclear.service.PathService;
  6. import com.iflytop.nuclear.service.TaskService;
  7. import com.iflytop.nuclear.utils.ResponseData;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.security.access.prepost.PreAuthorize;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.List;
  13. /**
  14. * @author cool
  15. * @date 2023/7/7 10:36
  16. */
  17. @Slf4j
  18. @RestController
  19. @CrossOrigin
  20. @RequestMapping("/path")
  21. @PreAuthorize("hasRole('ADMIN')")
  22. public class PathController {
  23. @Autowired
  24. TaskService taskService;
  25. @Autowired
  26. PathService pathService;
  27. @GetMapping("/check/{id}")
  28. public ResponseData check(@PathVariable(name = "id") int taskId) {
  29. Task task = taskService.getById(taskId);
  30. int status = task.getStatus();
  31. if (status != 0) {
  32. // 任务已经开始
  33. return ResponseData.fail("当前任务已经在流程中,不可更改路径规划");
  34. }
  35. return ResponseData.success();
  36. }
  37. @PostMapping("/plan/{id}")
  38. public ResponseData plan(@PathVariable(name = "id") int taskId, @RequestBody List<Path> pathList) {
  39. boolean b = pathService.plan(taskId, pathList);
  40. JSONObject jsonObject = new JSONObject();
  41. jsonObject.put("result", b);
  42. return ResponseData.success(jsonObject);
  43. }
  44. }