This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
enderbyendera-realtime-prot…/src/main/java/com/realtime/protection/server/task/TaskController.java

37 lines
1.2 KiB
Java
Raw Normal View History

package com.realtime.protection.server.task;
import com.realtime.protection.configuration.entity.task.Task;
import com.realtime.protection.configuration.response.ResponseResult;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/task")
public class TaskController {
private final TaskService taskService;
public TaskController(TaskService taskService) {
this.taskService = taskService;
}
@RequestMapping("/new")
public ResponseResult newTask(@RequestBody @Valid Task task) {
Integer taskId = taskService.newTask(task);
if (taskId > 0) {
return ResponseResult.ok()
.setData("task_name", task.getTaskName())
.setData("task_id", taskId)
.setData("success", true);
}
return ResponseResult.error()
.setData("task_name", task.getTaskName())
.setData("task_id", 0)
.setData("success", false);
}
}