1. 修改setDataMap函数为addDataMap以防止swagger将DataMap视为一种属性
2. 当任务未通过审核时,现在会立刻报错而不是返回false
This commit is contained in:
@@ -87,8 +87,7 @@ public class TaskController implements TaskControllerApi {
|
||||
return ResponseResult.invalid().setMessage("无效Task ID,也许该ID对应的任务不存在?");
|
||||
}
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setDataMap(EntityUtils.entityToMap(task));
|
||||
return ResponseResult.ok().setData("task", task);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.realtime.protection.configuration.entity.task.Task;
|
||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||
import com.realtime.protection.configuration.exception.DorisStartException;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
@@ -16,6 +17,10 @@ import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.fasterxml.jackson.databind.type.LogicalType.Map;
|
||||
|
||||
@Tag(name = "任务控制器API", description = "任务管理模块相关的所有接口")
|
||||
public interface TaskControllerApi {
|
||||
@PostMapping("/new")
|
||||
@@ -28,7 +33,8 @@ public interface TaskControllerApi {
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
)
|
||||
),
|
||||
responseCode = "200"
|
||||
)
|
||||
},
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "任务信息")
|
||||
|
||||
@@ -35,9 +35,9 @@ public class StateHandler {
|
||||
throw new IllegalArgumentException("无效的task_id,因为task_audit_status为空");
|
||||
}
|
||||
|
||||
// 如果审核状态不为已通过审核,则无效
|
||||
// 如果审核状态不为已通过审核,则报错
|
||||
if (taskAuditStatus != AuditStatus.AUDITED.getAuditStatus()) {
|
||||
return false;
|
||||
throw new IllegalArgumentException("无效的task_id,因为未通过审核");
|
||||
}
|
||||
|
||||
return switch (TaskTypeEnum.getTaskTypeByNum(task.getTaskType())) {
|
||||
|
||||
@@ -14,7 +14,8 @@ public class PendingState extends StateHandler implements State {
|
||||
case FAILED -> handleFailed(commandService, taskId);
|
||||
case RUNNING -> handleStart(taskService, commandService, taskId);
|
||||
case FINISHED -> handleFinish(commandService, taskId);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + StateEnum.getStateEnumByState(newState));
|
||||
default -> throw new IllegalStateException(taskId + " meets unexpected value: "
|
||||
+ StateEnum.getStateEnumByState(newState));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user