修改部分API注释bug
This commit is contained in:
EnderByEndera
2024-01-13 10:23:48 +08:00
parent 135a1ae04c
commit ee10a17aea
32 changed files with 201 additions and 173 deletions

View File

@@ -9,6 +9,8 @@ import com.realtime.protection.server.task.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
@Slf4j
public class StateChangeService {
@@ -22,9 +24,14 @@ public class StateChangeService {
@DSTransactional
public Boolean changeState(Integer stateNum, Long taskId) throws DorisStartException {
if (Objects.equals(stateNum, StateEnum.GENERATING.getStateNum()) ||
Objects.equals(stateNum, StateEnum.FAILED.getStateNum())) {
throw new IllegalArgumentException("非法任务状态:" + StateEnum.getStateByNum(stateNum));
}
Integer originalStateNum = taskService.queryTaskStatus(taskId);
if (originalStateNum == null) {
throw new IllegalArgumentException("cannot find status of task " + taskId + ", maybe task doesn't exist?");
throw new IllegalArgumentException("无法找到" + taskId + "的任务状态也许任务ID不存在?");
}
State originalState = StateEnum.getStateByNum(originalStateNum);
@@ -39,7 +46,7 @@ public class StateChangeService {
return false;
}
log.debug(String.format("successfully let task(%d) change state from %s to %s",
log.debug(String.format("成功使得task(%d)从%s切换为%s",
taskId,
originalState.getClass().getSimpleName(),
newState.getClass().getSimpleName()));

View File

@@ -16,13 +16,13 @@ public class StateHandler {
Task task = taskService.queryTask(taskId);
if (task == null) {
throw new IllegalArgumentException("invalid task id");
throw new IllegalArgumentException("无效task_id,因为无法找到对应任务");
}
Integer taskAuditStatus = task.getTaskAuditStatus();
if (taskAuditStatus == null) {
throw new IllegalArgumentException("invalid task id, because task_audit_status is null");
throw new IllegalArgumentException("无效的task_id,因为task_audit_status为空");
}
// 如果审核状态不为已通过审核,则无效
@@ -74,7 +74,7 @@ public class StateHandler {
// 如果未能获取staticTaskCommandInfos需要报错
List<TaskCommandInfo> staticTaskCommandInfos = taskService.getStaticCommandInfos(taskId);
if (staticTaskCommandInfos == null || staticTaskCommandInfos.isEmpty()) {
throw new IllegalArgumentException("static rules are empty, need to choose at least one static rule");
throw new IllegalArgumentException("静态规则列表为空,请至少选择一个静态规则以启动任务");
}
commandService.createCommands(staticTaskCommandInfos);