1. 完成新建任务功能,但是未完成静态关键信息功能和动态关键信息功能的关联,需要相关人员沟通

2. 完成新建配置模板功能
3. 修改configuration文件夹中全局异常处理器,添加了几种专门处理数据库异常和Valid异常的处理器。
4. 修改application.yml文件,将hikari自动提交设置为false,此项设置可用于避免数据库发生脏读
This commit is contained in:
松岳 陈
2024-01-03 09:13:22 +08:00
parent 66c710c034
commit 68cd466c9f
16 changed files with 521 additions and 5 deletions

View File

@@ -0,0 +1,36 @@
package com.realtime.protection.configuration.entity.defense.template;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class Template {
@JsonProperty("template_id")
private Integer templateId;
@JsonProperty("template_name")
@NotNull(message = "template name should not be empty")
private String templateName;
@JsonProperty("template_elements")
private String[] templateElements;
@JsonProperty("default_op")
@NotNull(message = "default_op should not be empty")
private String defaultOp;
private boolean hasProtectObjectIP;
private boolean hasProtectObjectPort;
private boolean hasPeerIP;
private boolean hasPeerPort;
private boolean hasProtocol;
private boolean hasURL;
private boolean hasDNS;
}

View File

@@ -0,0 +1,69 @@
package com.realtime.protection.configuration.entity.task;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class Task {
@JsonProperty("task_id")
private Integer taskId;
@JsonProperty("task_name")
@NotNull(message = "task_name should not be empty")
private String taskName;
@JsonProperty("task_start_time")
@NotNull(message = "task_start_time should not be empty")
private LocalDateTime taskStartTime;
@JsonProperty("task_end_time")
@NotNull(message = "task_end_time should not be empty")
private LocalDateTime taskEndTime;
@JsonProperty("task_create_time")
private LocalDateTime taskCreateTime;
@JsonProperty("task_modify_time")
private LocalDateTime taskModifyTime;
@JsonProperty("task_type")
@NotNull(message = "task_type should not be empty")
private String taskType;
@JsonProperty("task_act")
@NotNull(message = "task_act should not be empty")
private String taskAct;
// These three attributes will be gained by user in the future
// -----------------------------------------------------------
@JsonProperty("task_create_username")
@NotNull(message = "task_create_username should not be empty")
private String taskCreateUsername;
@JsonProperty("task_create_depart")
@NotNull(message = "task_create_depart should not be empty")
private String taskCreateDepart;
@JsonProperty("task_create_userid")
@NotNull(message = "task_create_userid should not be empty")
private Integer taskCreateUserId;
// -----------------------------------------------------------
@JsonProperty("static_rule_ids")
private Integer[] staticRuleIds;
@JsonProperty("dynamic_rule_ids")
private Integer[] dynamicRuleIds;
@JsonProperty("protect_object_ids")
private Integer[] protectObjectIds;
@JsonProperty("task_status")
private Integer taskStatus;
@JsonProperty("task_audit_status")
private Integer taskAuditStatus;
}

View File

@@ -1,18 +1,49 @@
package com.realtime.protection.configuration.exception;
import cn.dev33.satoken.exception.NotLoginException;
import com.realtime.protection.configuration.response.ResponseResult;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.stream.Collectors;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler
@Order(3)
@ExceptionHandler(value = Exception.class)
public ResponseResult handleGlobalException(Exception e) {
return ResponseResult.error().setMessage(e.getMessage());
}
@Order(2)
@ExceptionHandler(value = NotLoginException.class)
public ResponseResult handleNotLoginException(NotLoginException e) {
return new ResponseResult(
400,
e.getMessage()
);
}
@Order(2)
@ExceptionHandler(value = PersistenceException.class)
public ResponseResult handleSQLException() {
return new ResponseResult(
400,
"please check the integrity of the data. check if the json data exists in the database");
}
@Order(2)
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
return new ResponseResult(
400,
e.getBindingResult().getAllErrors().stream()
.map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining())
);
}
}