1. 添加HandlerMethodValidationException全局异常器

2. 新增防护对象类,添加Service、Mapper、Controller(Controller仍然在开发中)
3. page和pageSize添加@Min注解,限定最低整数大小
4. 将所有的批量类型方法修改为forEach,在SpringBoot中循环执行并整合为事务
This commit is contained in:
松岳 陈
2024-01-05 09:32:19 +08:00
parent b4db26c856
commit 776c7c0f6d
19 changed files with 327 additions and 82 deletions

View File

@@ -0,0 +1,45 @@
package com.realtime.protection.configuration.entity.defense.object;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class ProtectObject {
@JsonProperty("proobj_id")
private Integer protectObjectId;
@JsonProperty("proobj_name")
@NotNull(message = "proobj_name should not be empty.")
private String protectObjectName;
@JsonProperty("proobj_system_name")
private String protectObjectSystemName;
@JsonProperty("proobj_ip_address")
private String protectObjectIPAddress;
@JsonProperty("proobj_port")
@NotNull(message = "proobj_port should not be empty.")
private Integer protectObjectPort;
@JsonProperty("proobj_url")
@NotNull(message = "proobj_url should not be empty.")
private String protectObjectURL;
@JsonProperty("proobj_protocol")
@NotNull(message = "proobj_protocol should not be empty.")
private String protectObjectProtocol;
@JsonProperty("proobj_audit_status")
private Integer protectObjectAuditStatus;
@JsonProperty("proobj_create_username")
private String protectObjectCreateUsername;
@JsonProperty("proobj_create_depart")
private String protectObjectCreateDepart;
@JsonProperty("proobj_create_userid")
private Integer protectObjectCreateUserId;
}

View File

@@ -4,20 +4,22 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Data
public class Template {
@JsonProperty("template_id")
private Integer templateId;
@JsonProperty("template_name")
@NotNull(message = "template name should not be empty")
@NotNull(message = "template name should not be empty.")
private String templateName;
@JsonProperty("template_elements")
private String[] templateElements;
private List<String> templateElements;
@JsonProperty("default_op")
@NotNull(message = "default_op should not be empty")
@NotNull(message = "default_op should not be empty.")
private String defaultOp;
@JsonProperty("template_running_tasks")

View File

@@ -13,15 +13,15 @@ public class Task {
private Integer taskId;
@JsonProperty("task_name")
@NotNull(message = "task_name should not be empty")
@NotNull(message = "task_name should not be empty.")
private String taskName;
@JsonProperty("task_start_time")
@NotNull(message = "task_start_time should not be empty")
@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")
@NotNull(message = "task_end_time should not be empty.")
private LocalDateTime taskEndTime;
@JsonProperty("task_create_time")
@@ -31,27 +31,21 @@ public class Task {
private LocalDateTime taskModifyTime;
@JsonProperty("task_type")
@NotNull(message = "task_type should not be empty")
@NotNull(message = "task_type should not be empty.")
private String taskType;
@JsonProperty("task_act")
@NotNull(message = "task_act should not be empty")
@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 List<Integer> staticRuleIds;

View File

@@ -3,13 +3,13 @@ package com.realtime.protection.configuration.exception;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.SaTokenException;
import com.realtime.protection.configuration.response.ResponseResult;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
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 org.springframework.web.method.annotation.HandlerMethodValidationException;
import java.util.stream.Collectors;
@@ -47,6 +47,12 @@ public class GlobalExceptionHandler {
);
}
@Order(2)
@ExceptionHandler(value = HandlerMethodValidationException.class)
public ResponseResult handleHandlerMethodValidationException(HandlerMethodValidationException e) {
return ResponseResult.invalid().setMessage(e.getMessage());
}
@Order(2)
@ExceptionHandler(value = SaTokenException.class)
public ResponseResult handleSaTokenException(SaTokenException e) {