1. 添加doris数据源

2. 添加StateMapper,准备进行oracle数据库对接
This commit is contained in:
EnderByEndera
2024-01-09 09:20:13 +08:00
parent 2b04a7d6ce
commit a04b83e4c3
15 changed files with 134 additions and 39 deletions

View File

@@ -1,8 +1,11 @@
package com.realtime.protection.server.task;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.realtime.protection.configuration.entity.task.Task;
import com.realtime.protection.configuration.utils.status.AuditStatusValidator;
import com.realtime.protection.server.task.state.PauseState;
import com.realtime.protection.server.task.state.RunningState;
import com.realtime.protection.server.task.state.State;
import com.realtime.protection.server.task.state.StopState;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -61,4 +64,29 @@ public class TaskService {
public Boolean deleteTask(Integer taskId) {
return taskMapper.deleteTask(taskId);
}
@Transactional
public Boolean changeTaskStatus(Integer taskId, Integer stateNum) {
State originalState = switch (taskMapper.queryTask(taskId).getTaskStatus()) {
// 运行中
case 1 -> new RunningState();
// 暂停中
case 2 -> new PauseState();
// 停止中
case 3 -> new StopState();
default -> throw new IllegalArgumentException();
};
State newState = switch (stateNum) {
// 运行中
case 1 -> new RunningState();
// 暂停中
case 2 -> new PauseState();
// 停止中
case 3 -> new StopState();
default -> throw new IllegalArgumentException();
};
return StatusChanger.setOriginal(originalState).changeState(newState);
}
}