1. 添加部分swagger文档

This commit is contained in:
EnderByEndera
2024-01-12 14:31:34 +08:00
parent 8f545110f1
commit c1a5d2462f
30 changed files with 614 additions and 65 deletions

View File

@@ -31,6 +31,10 @@ public class StateChangeService {
State newState = StateEnum.getStateByNum(stateNum);
if (newState == null) {
return false;
}
if (!originalState.handle(newState, commandService, taskService, taskId)) {
return false;
}

View File

@@ -77,13 +77,7 @@ public class StateHandler {
throw new IllegalArgumentException("static rules are empty, need to choose at least one static rule");
}
try {
commandService.createCommands(staticTaskCommandInfos);
} catch (DorisStartException e) {
e.taskId = taskId;
throw e;
}
commandService.createCommands(staticTaskCommandInfos);
return true;
}
}

View File

@@ -0,0 +1,19 @@
package com.realtime.protection.server.task.status.states;
import com.realtime.protection.configuration.exception.DorisStartException;
import com.realtime.protection.configuration.utils.enums.StateEnum;
import com.realtime.protection.configuration.utils.status.State;
import com.realtime.protection.server.command.CommandService;
import com.realtime.protection.server.task.TaskService;
import com.realtime.protection.server.task.status.StateHandler;
public class GeneratingState extends StateHandler implements State {
@Override
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) throws DorisStartException {
return switch(StateEnum.getStateEnumByState(newState)) {
case RUNNING, GENERATING -> true;
case FAILED -> handleFailed(commandService, taskId);
default -> throw new IllegalStateException("Unexpected value: " + StateEnum.getStateEnumByState(newState));
};
}
}

View File

@@ -11,7 +11,7 @@ public class PendingState extends StateHandler implements State {
@Override
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) throws DorisStartException {
return switch (StateEnum.getStateEnumByState(newState)) {
case RUNNING -> handleStart(taskService, commandService, taskId);
case GENERATING -> handleStart(taskService, commandService, taskId);
case FAILED -> handleFailed(commandService, taskId);
default -> throw new IllegalStateException("Unexpected value: " + StateEnum.getStateEnumByState(newState));
};

View File

@@ -10,7 +10,7 @@ public class RunningState extends StateHandler implements State {
@Override
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) {
return switch(StateEnum.getStateEnumByState(newState)) {
case RUNNING -> true;
case RUNNING, GENERATING -> true;
case PAUSED -> handlePause(commandService, taskId);
case STOP -> handleStop(commandService, taskId);
case FINISHED -> handleFinish(commandService, taskId);