核查系统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

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/{id}")
public ResponseData plan(@PathVariable(name = "id") int taskId, @RequestBody List<Path> pathList) {
boolean b = pathService.plan(taskId, pathList);
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", b);
return ResponseData.success(jsonObject);
}
}