hotfix:
修改部分API注释bug
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
# SSFY系统 README
|
||||
|
||||
## 项目文件夹结构说明:
|
||||
|
||||
目前整体分为两大板块:**configuration**和**server**
|
||||
|
||||
### Configuration
|
||||
|
||||
所有业务的配置,包括切面、拦截器、中间件、消息处理等配置全部放置于此处。
|
||||
任何带@Configuration注解的配置均放置于此
|
||||
|
||||
### server
|
||||
|
||||
server主要存放所有的业务逻辑以及Mapper接口。业务逻辑和Mapper需要按照业务进行划分进行分开放置
|
||||
|
||||
---
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ProtectObject {
|
||||
private Integer protectObjectId;
|
||||
|
||||
@JsonProperty("proobj_name")
|
||||
@NotNull(message = "proobj_name should not be empty.")
|
||||
@NotNull(message = "proobj_name字段不能为空。")
|
||||
@ExcelProperty("名称")
|
||||
@Schema(description = "防护对象名称", example = "静态对象测试")
|
||||
private String protectObjectName;
|
||||
@@ -35,21 +35,21 @@ public class ProtectObject {
|
||||
private String protectObjectIPAddress;
|
||||
|
||||
@JsonProperty("proobj_port")
|
||||
@NotNull(message = "proobj_port should not be empty.")
|
||||
@Max(value = 65535, message = "port should not be more than 65535")
|
||||
@Min(value = 1, message = "port should not be less than 1")
|
||||
@NotNull(message = "proobj_port字段不能为空。")
|
||||
@Max(value = 65535, message = "端口号不能大于65535。")
|
||||
@Min(value = 1, message = "端口号不能小于1。")
|
||||
@ExcelProperty("端口")
|
||||
@Schema(description = "防护对象端口", maximum = "65535", minimum = "1", example = "8080")
|
||||
private Integer protectObjectPort;
|
||||
|
||||
@JsonProperty("proobj_url")
|
||||
@NotNull(message = "proobj_url should not be empty.")
|
||||
@NotNull(message = "proobj_url字段不能为空。")
|
||||
@ExcelProperty("URL")
|
||||
@Schema(description = "防护对象URL", example = "alice.bob.com")
|
||||
private String protectObjectURL;
|
||||
|
||||
@JsonProperty("proobj_protocol")
|
||||
@NotNull(message = "proobj_protocol should not be empty.")
|
||||
@NotNull(message = "proobj_protocol字段不能为空")
|
||||
@ExcelProperty("协议")
|
||||
@Schema(description = "防护对象网络协议(目前仅可以填写TCP或UDP)", example = "TCP")
|
||||
private String protectObjectProtocol;
|
||||
|
||||
@@ -12,27 +12,27 @@ public class Template {
|
||||
private Integer templateId;
|
||||
|
||||
@JsonProperty("template_name")
|
||||
@NotNull(message = "template name should not be empty.")
|
||||
@NotNull(message = "template_name字段不能为空。")
|
||||
@Schema(description = "防御策略模板名称", example = "自定义模板")
|
||||
private String templateName;
|
||||
|
||||
@JsonProperty("source_system")
|
||||
@NotNull(message = "source_system should not be empty. ")
|
||||
@NotNull(message = "source_system字段不能为空。")
|
||||
@Schema(description = "防御策略模板数据来源系统", example = "BW系统")
|
||||
private String sourceSystem;
|
||||
|
||||
@JsonProperty("protect_level_low")
|
||||
@NotNull(message = "protect_level_low should not be empty. ")
|
||||
@NotNull(message = "protect_level_low字段不能为空。")
|
||||
@Schema(description = "防御策略模板日常态字段提取选项")
|
||||
private ProtectLevel protectLevelLow;
|
||||
|
||||
@JsonProperty("protect_level_medium")
|
||||
@NotNull(message = "protect_level_medium should not be empty. ")
|
||||
@NotNull(message = "protect_level_medium字段不能为空。")
|
||||
@Schema(description = "防御策略模板应急态字段提取选项")
|
||||
private ProtectLevel protectLevelMedium;
|
||||
|
||||
@JsonProperty("protect_level_high")
|
||||
@NotNull(message = "protect_level_high should not be empty. ")
|
||||
@NotNull(message = "protect_level_high字段不能为空。")
|
||||
@Schema(description = "防御策略模板紧急态字段提取选项")
|
||||
private ProtectLevel protectLevelHigh;
|
||||
|
||||
|
||||
@@ -17,19 +17,19 @@ public class Task {
|
||||
private Long taskId;
|
||||
|
||||
@JsonProperty("task_name")
|
||||
@NotNull(message = "task_name should not be empty. ")
|
||||
@NotNull(message = "task_name字段不能为空。")
|
||||
@Schema(description = "任务名称", example = "静态任务")
|
||||
private String taskName;
|
||||
|
||||
@JsonProperty("task_start_time")
|
||||
@NotNull(message = "task_start_time should not be empty. ")
|
||||
@Future(message = "task_start_time should be a future time")
|
||||
@NotNull(message = "task_start_time字段不能为空。")
|
||||
@Future(message = "task_start_time必须晚于当前时间。")
|
||||
@Schema(description = "任务开始时间,必须晚于当前时间", example = "2024-10-23T00:00:00")
|
||||
private LocalDateTime taskStartTime;
|
||||
|
||||
@JsonProperty("task_end_time")
|
||||
@NotNull(message = "task_end_time should not be empty. ")
|
||||
@Future(message = "task_end_time should be a future time. ")
|
||||
@NotNull(message = "task_end_time字段不能为空。")
|
||||
@Future(message = "task_end_time必须晚于当前时间。")
|
||||
@Schema(description = "任务结束时间,必须晚于开始时间", example = "2024-10-24T00:00:00")
|
||||
private LocalDateTime taskEndTime;
|
||||
|
||||
@@ -42,12 +42,12 @@ public class Task {
|
||||
private LocalDateTime taskModifyTime;
|
||||
|
||||
@JsonProperty("task_type")
|
||||
@NotNull(message = "task_type should not be empty. ")
|
||||
@NotNull(message = "task_type字段不能为空。")
|
||||
@Schema(description = "任务类型,1为静态任务,2为实时任务,3为研判后任务", example = "1")
|
||||
private Integer taskType;
|
||||
|
||||
@JsonProperty("task_act")
|
||||
@NotNull(message = "task_act should not be empty. ")
|
||||
@NotNull(message = "task_act字段不能为空。")
|
||||
@Schema(description = "任务行为,目前只能为【阻断】", example = "阻断")
|
||||
private String taskAct;
|
||||
|
||||
|
||||
@@ -30,30 +30,23 @@ public class GlobalExceptionHandler {
|
||||
@Order(3)
|
||||
@ExceptionHandler(value = {Exception.class})
|
||||
public ResponseResult handleGlobalException(Exception e) {
|
||||
log.error("meets global exception: " + e.getMessage());
|
||||
log.error("遭遇全局异常:" + e.getMessage());
|
||||
return ResponseResult.error().setMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = {PersistenceException.class})
|
||||
public ResponseResult handleSQLException(PersistenceException e) {
|
||||
log.error("meets database exception: " + e.getMessage());
|
||||
@ExceptionHandler(value = {PersistenceException.class, DuplicateKeyException.class})
|
||||
public ResponseResult handleSQLException(Exception e) {
|
||||
log.info("遭遇数据库异常:" + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage(
|
||||
"please check the integrity of the data. check if the json data exists in the database");
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = DuplicateKeyException.class)
|
||||
public ResponseResult handleDuplicateKeyException(DuplicateKeyException e) {
|
||||
log.debug("meets duplicate key exception: " + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage("duplicate key in json data");
|
||||
"请检查json字段的完整性,确保json字段按照文档中要求填写。");
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
|
||||
log.debug("meets data bind exception: " + e.getMessage());
|
||||
log.debug("遭遇数据绑定异常:" + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage(
|
||||
e.getBindingResult().getAllErrors().stream()
|
||||
.map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining())
|
||||
@@ -67,14 +60,14 @@ public class GlobalExceptionHandler {
|
||||
IllegalStateException.class
|
||||
})
|
||||
public ResponseResult handleHandlerMethodValidationException(Exception e) {
|
||||
log.debug("meets illegal argument exception: " + e.getMessage());
|
||||
log.debug("遭遇非法参数异常:" + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage(e.getMessage());
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = NotLoginException.class)
|
||||
public ResponseResult handleNotLoginException(NotLoginException e) {
|
||||
log.debug("meets not login exception, login type: " + e.getLoginType());
|
||||
log.debug("遭遇Sa-Token登录异常,登录类型为:" + e.getLoginType());
|
||||
return new ResponseResult(
|
||||
401,
|
||||
e.getMessage()
|
||||
@@ -84,16 +77,16 @@ public class GlobalExceptionHandler {
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = SaTokenException.class)
|
||||
public ResponseResult handleSaTokenException(SaTokenException e) {
|
||||
log.debug("sa-token meets exception: " + e.getMessage());
|
||||
log.debug("Sa-token模块遭遇异常:" + e.getMessage());
|
||||
return ResponseResult.unAuthorized().setMessage(e.getMessage());
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = DorisStartException.class)
|
||||
public ResponseResult handleDorisStartException(DorisStartException e) {
|
||||
log.warn("doris database meets exception: " + e.getMessage());
|
||||
log.warn("Doris数据库遭遇异常:" + e.getMessage());
|
||||
ResponseResult responseResult = ResponseResult.error()
|
||||
.setMessage("Doris command creation meets error: " + e.getMessage());
|
||||
.setMessage("Doris数据库指令生成遭遇异常:" + e.getMessage());
|
||||
|
||||
try {
|
||||
stateChangeService.changeState(StateEnum.FAILED.getStateNum(), e.taskId);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CommandService {
|
||||
commandBatch.clear();
|
||||
}
|
||||
|
||||
log.debug(String.format("create all the commands from task(%d), rule(%d)",
|
||||
log.debug(String.format("在task(%d)和rule(%d)中构建了全部指令",
|
||||
info.getTaskId(), info.getRuleId()));
|
||||
return null;
|
||||
};
|
||||
@@ -68,6 +68,7 @@ public class CommandService {
|
||||
public void createCommand(TaskCommandInfo commandInfo) throws DorisStartException {
|
||||
try {
|
||||
sqlSessionWrapper.startBatchSession(CommandMapper.class, createCommandBatchFunction, commandInfo);
|
||||
taskService.changeTaskStatus(commandInfo.getTaskId(), StateEnum.RUNNING.getStateNum());
|
||||
} catch (Exception e) {
|
||||
throw new DorisStartException(e, commandInfo.getTaskId());
|
||||
}
|
||||
@@ -92,7 +93,10 @@ public class CommandService {
|
||||
try {
|
||||
sqlSessionWrapper.startBatchSession(CommandMapper.class, function, taskCommandInfos);
|
||||
} catch (Exception e) {
|
||||
TaskCommandInfo info = taskCommandInfos.get(0);
|
||||
TaskCommandInfo info = null;
|
||||
if (taskCommandInfos != null) {
|
||||
info = taskCommandInfos.get(0);
|
||||
}
|
||||
Long taskId = null;
|
||||
if (info != null) {
|
||||
taskId = info.getTaskId();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ProjectObjectDataListener implements ReadListener<ProtectObject> {
|
||||
private void saveData() {
|
||||
Boolean success = protectObjectService.newProtectObjects(cachedDataList);
|
||||
if (!success) {
|
||||
throw new RuntimeException("Error reading data in /proobj/new");
|
||||
throw new RuntimeException("在/proobj/upload中读取数据时出现了错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
||||
@Override
|
||||
@PostMapping("/upload")
|
||||
public ResponseResult uploadFile(
|
||||
@NotNull(message = "uploadFile cannot be null. ") MultipartFile uploadFile
|
||||
@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile
|
||||
) throws IOException {
|
||||
EasyExcel.read(uploadFile.getInputStream(), ProtectObject.class,
|
||||
new ProjectObjectDataListener(protectObjectService)).sheet().doRead();
|
||||
@@ -85,6 +85,10 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
||||
@GetMapping("/{protectObjectId}/query")
|
||||
public ResponseResult queryProtectObject(@PathVariable Integer protectObjectId) throws IllegalAccessException {
|
||||
ProtectObject protectObject = protectObjectService.queryProtectObject(protectObjectId);
|
||||
if (protectObject == null) {
|
||||
return ResponseResult.invalid()
|
||||
.setMessage("无效的防护对象ID,也许该ID指定的防护对象不存在?");
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.setDataMap(EntityUtils.entityToMap(protectObject));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface ProtectObjectControllerApi {
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "上传文件")
|
||||
)
|
||||
ResponseResult uploadFile(
|
||||
@NotNull(message = "uploadFile cannot be null. ") MultipartFile uploadFile
|
||||
@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile
|
||||
) throws IOException;
|
||||
|
||||
@GetMapping("/download")
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ProtectObjectService {
|
||||
public Map<String, Object> changeProtectObjectAuditStatus(Integer protectObjectId, Integer auditStatus) {
|
||||
Integer originalAuditStatus = protectObjectMapper.queryProtectObject(protectObjectId).getProtectObjectAuditStatus();
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
throw new IllegalArgumentException("invalid audit status");
|
||||
throw new IllegalArgumentException("无效的审核状态");
|
||||
}
|
||||
Boolean success = protectObjectMapper.changeProtectObjectAuditStatus(protectObjectId, auditStatus);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TemplateController implements TemplateControllerApi {
|
||||
Template template = templateService.queryTemplate(templateId);
|
||||
if (template == null) {
|
||||
return ResponseResult.invalid()
|
||||
.setMessage("invalid templateId, maybe this template doesn't exist?");
|
||||
.setMessage("无效的策略模板ID,也许该模板不存在?");
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.setDataMap(EntityUtils.entityToMap(template));
|
||||
|
||||
@@ -99,7 +99,7 @@ public class TaskController implements TaskControllerApi {
|
||||
|
||||
@Override
|
||||
@GetMapping("/{taskId}/running/{stateNum}")
|
||||
public ResponseResult changeTaskStatus(@PathVariable @NotNull Integer stateNum,
|
||||
public ResponseResult changeTaskStatus(@PathVariable @NotNull @Min(0) @Max(6) Integer stateNum,
|
||||
@PathVariable @NotNull Long taskId) throws DorisStartException {
|
||||
return ResponseResult.ok()
|
||||
.setData("task_id", taskId)
|
||||
|
||||
@@ -160,6 +160,6 @@ public interface TaskControllerApi {
|
||||
@Parameter(name = "stateNum", description = "任务状态编号任务状态(0为未启动,1为生成中,2为运行中,3为暂停中,4为已停止,5为已结束,6为失败)")
|
||||
}
|
||||
)
|
||||
ResponseResult changeTaskStatus(@PathVariable @NotNull Integer stateNum,
|
||||
ResponseResult changeTaskStatus(@PathVariable @NotNull @Min(0) @Max(6) Integer stateNum,
|
||||
@PathVariable @NotNull Long taskId) throws DorisStartException;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TaskService {
|
||||
public Boolean changeTaskAuditStatus(Long taskId, Integer taskAuditStatus) {
|
||||
Integer originalAuditStatus = taskMapper.queryTaskAuditStatus(taskId);
|
||||
if (originalAuditStatus == null) {
|
||||
throw new IllegalArgumentException("cannot find audit status of task " + taskId + ", maybe task doesn't exist?");
|
||||
throw new IllegalArgumentException("无法找到任务ID为" + taskId + "的任务,也许任务不存在?");
|
||||
}
|
||||
|
||||
if (AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(taskAuditStatus))
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -189,6 +189,4 @@ public interface WhiteListControllerApi {
|
||||
@PathVariable Integer auditStatus);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -52,3 +52,8 @@ springdoc:
|
||||
swagger-ui:
|
||||
path: /swagger
|
||||
packages-to-scan: com.realtime.protection.server
|
||||
|
||||
management:
|
||||
endpoint:
|
||||
shutdown:
|
||||
enabled: true
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
dynamic_rule_create_depart, template_id, dynamic_rule_protect_level,
|
||||
dynamic_rule_priority, dynamic_rule_range,
|
||||
dynamic_rule_frequency, dynamic_rule_create_user_id)
|
||||
values
|
||||
(#{object.dynamicRuleName},
|
||||
values (#{object.dynamicRuleName},
|
||||
#{object.dynamicRuleCreateTime}, #{object.dynamicRuleModifyTime},
|
||||
#{object.dynamicRuleCreateUsername}, #{object.dynamicRuleCreateDepart},
|
||||
#{object.templateId}, #{object.dynamicRuleProtectLevel},
|
||||
@@ -26,8 +25,7 @@
|
||||
</insert>
|
||||
|
||||
<insert id="newDynamicRulProtectObjectConcat">
|
||||
insert into
|
||||
t_protect_object_dynamic_rule_conn(dynamic_rule_id, protect_object_id)
|
||||
insert into t_protect_object_dynamic_rule_conn(dynamic_rule_id, protect_object_id)
|
||||
values (#{dynamicRuleId}, #{protectObjectId})
|
||||
</insert>
|
||||
<insert id="newDynamicRules">
|
||||
@@ -58,12 +56,14 @@
|
||||
<!-- # on t_dynamic_rule.dynamic_rule_id = t_protect_object_dynamic_rule_conn.dynamic_rule_id-->
|
||||
<!-- # where t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}-->
|
||||
<delete id="deleteDynamicRuleObject">
|
||||
delete from t_dynamic_rule
|
||||
delete
|
||||
from t_dynamic_rule
|
||||
where dynamic_rule_id = #{dynamicRuleId}
|
||||
</delete>
|
||||
<!-- 用于update时删去之前的关联-->
|
||||
<delete id="deleteDynamicRuleProtectObjectConcat">
|
||||
delete from t_protect_object_dynamic_rule_conn
|
||||
delete
|
||||
from t_protect_object_dynamic_rule_conn
|
||||
where dynamic_rule_id = #{dynamicRuleId}
|
||||
</delete>
|
||||
|
||||
@@ -82,7 +82,9 @@
|
||||
<if test="object.dynamicRuleName != null">dynamic_rule_name = #{object.dynamicRuleName},</if>
|
||||
<if test="object.dynamicRuleModifyTime != null">modify_time = #{object.dynamicRuleModifyTime},</if>
|
||||
<if test="object.templateId != null">template_id = #{object.templateId},</if>
|
||||
<if test="object.dynamicRuleProtectLevel != null"> dynamic_rule_protect_level = #{object.dynamicRuleProtectLevel},</if>
|
||||
<if test="object.dynamicRuleProtectLevel != null">dynamic_rule_protect_level =
|
||||
#{object.dynamicRuleProtectLevel},
|
||||
</if>
|
||||
<if test="object.dynamicRulePriority != null">dynamic_rule_priority = #{object.dynamicRulePriority},</if>
|
||||
<if test="object.dynamicRuleRange != null">dynamic_rule_range = #{object.dynamicRuleRange},</if>
|
||||
<if test="object.dynamicRuleFrequency != null">dynamic_rule_frequency = #{object.dynamicRuleFrequency}</if>
|
||||
@@ -91,7 +93,8 @@
|
||||
</update>
|
||||
|
||||
|
||||
<resultMap id="dynamicRuleMap" type="com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject">
|
||||
<resultMap id="dynamicRuleMap"
|
||||
type="com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject">
|
||||
<id column="dynamic_rule_id" property="dynamicRuleId"/>
|
||||
<result column="dynamic_rule_name" property="dynamicRuleName"/>
|
||||
<result column="create_time" property="dynamicRuleCreateTime"/>
|
||||
|
||||
@@ -121,11 +121,13 @@
|
||||
</select>
|
||||
|
||||
<select id="queryStaticRuleById" resultMap="staticRuleMap">
|
||||
SELECT * FROM t_static_rule
|
||||
SELECT *
|
||||
FROM t_static_rule
|
||||
WHERE static_rule_id = #{static_rule_id}
|
||||
</select>
|
||||
<select id="queryAuditStatusById" resultType="java.lang.Integer">
|
||||
SELECT static_rule_audit_status FROM t_static_rule
|
||||
SELECT static_rule_audit_status
|
||||
FROM t_static_rule
|
||||
WHERE static_rule_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@SpringBootTest
|
||||
public class DynamicRuleServiceTest {
|
||||
private final DynamicRuleService dynamicRuleService;
|
||||
|
||||
@Autowired
|
||||
public DynamicRuleServiceTest(DynamicRuleService dynamicRuleService) {
|
||||
this.dynamicRuleService = dynamicRuleService;
|
||||
|
||||
@@ -16,6 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
public class StaticRuleServiceTest {
|
||||
private final StaticRuleService staticRuleService;
|
||||
private StaticRuleObject staticRuleTest;
|
||||
|
||||
@Autowired
|
||||
public StaticRuleServiceTest(StaticRuleService staticRuleService) {
|
||||
this.staticRuleService = staticRuleService;
|
||||
@@ -63,6 +64,7 @@ public class StaticRuleServiceTest {
|
||||
}
|
||||
//assertTrue(id>0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewStaticRules() {
|
||||
List<StaticRuleObject> staticRuleObjects = new ArrayList<>();
|
||||
@@ -83,6 +85,7 @@ public class StaticRuleServiceTest {
|
||||
staticRuleService.deleteStaticRules(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateStaticRule() {
|
||||
|
||||
@@ -104,6 +107,7 @@ public class StaticRuleServiceTest {
|
||||
|
||||
staticRuleService.updateStaticRule(5, object);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryStaticRule() {
|
||||
|
||||
|
||||
@@ -49,7 +49,10 @@ class TaskServiceTest {
|
||||
LocalDateTime taskEndTime = LocalDateTime.now().plusDays(i + 10);
|
||||
task.setTaskStartTime(taskStartTime);
|
||||
task.setTaskEndTime(taskEndTime);
|
||||
assertDoesNotThrow(() -> {Long taskId = taskService.newTask(task); assertTrue(taskId > 0);});
|
||||
assertDoesNotThrow(() -> {
|
||||
Long taskId = taskService.newTask(task);
|
||||
assertTrue(taskId > 0);
|
||||
});
|
||||
assertTrue(task.getTaskId() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,14 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SpringBootTest
|
||||
class WhiteListServiceTest {
|
||||
|
||||
private final WhiteListService whiteListService;
|
||||
private WhiteListObject whiteListObject;
|
||||
|
||||
@Autowired
|
||||
WhiteListServiceTest(WhiteListService whiteListService) {
|
||||
this.whiteListService = whiteListService;
|
||||
|
||||
Reference in New Issue
Block a user