1. application.yml修改为application-dev.yml和application-prod.yml
2. 添加更多Exception拦截器 3. 编写状态模式处理task状态的更改 4. 添加StateChangeService,用以处理所有任务状态转换相关的内容 5. 添加StateEnum, ProtocolEnum,TaskTypeEnum用以处理任务和协议相关的所有状态和类型
This commit is contained in:
@@ -4,8 +4,6 @@ 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")
|
||||
@@ -37,6 +35,12 @@ public class Template {
|
||||
@NotNull(message = "protect_level_high should not be empty. ")
|
||||
private ProtectLevel protectLevelHigh;
|
||||
|
||||
@JsonProperty("template_used_times")
|
||||
private Integer usedTimes;
|
||||
|
||||
@JsonProperty("running_tasks")
|
||||
private Integer runningTasks;
|
||||
|
||||
private Integer createUserId;
|
||||
|
||||
private String createUsername;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class DynamicRuleObject {
|
||||
@JsonProperty("dynamic_rule_create_username")
|
||||
private String dynamicRuleCreateUsername;
|
||||
|
||||
// @JsonProperty("dynamic_rule_audit_status")
|
||||
// @JsonProperty("dynamic_rule_audit_status")
|
||||
// private Integer dynamicRuleAuditStatus;
|
||||
@JsonProperty("dynamic_rule_create_depart")
|
||||
private String dynamicRuleCreateDepart;
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
package com.realtime.protection.configuration.entity.task;
|
||||
|
||||
import com.realtime.protection.configuration.utils.enums.ProtocolEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class Command {
|
||||
private Integer id;
|
||||
private FiveTupleWithMask fiveTupleWithMask;
|
||||
private Long taskId;
|
||||
|
||||
private Integer type;
|
||||
private String sourceIP;
|
||||
private String sourcePort;
|
||||
private String destinationIP;
|
||||
private String destinationPort;
|
||||
private Integer protocol;
|
||||
private String operation;
|
||||
private LocalDateTime validTime;
|
||||
private LocalDateTime invalidTime;
|
||||
|
||||
private String maskSourceIP;
|
||||
private String maskSourcePort;
|
||||
private String maskDestinationIP;
|
||||
private String maskDestinationPort;
|
||||
private Integer direction;
|
||||
public static Command generateCommand(TaskCommandInfo info, LocalDateTime validTime) {
|
||||
Command command = new Command();
|
||||
|
||||
private LocalDateTime datetime;
|
||||
FiveTupleWithMask fiveTupleWithMask = info.getFiveTupleWithMask();
|
||||
if (fiveTupleWithMask.getProtocol() != null)
|
||||
fiveTupleWithMask.setProtocolNum(ProtocolEnum.valueOf(fiveTupleWithMask.getProtocol()).getProtocolNumber());
|
||||
|
||||
command.setFiveTupleWithMask(fiveTupleWithMask);
|
||||
command.setTaskId(info.getTaskId());
|
||||
command.setOperation(info.getOperation());
|
||||
command.setValidTime(validTime);
|
||||
command.setInvalidTime(info.getEndTime());
|
||||
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.realtime.protection.configuration.entity.task;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FiveTupleWithMask {
|
||||
private Integer addrType;
|
||||
private String sourceIP;
|
||||
private String sourcePort;
|
||||
private String destinationIP;
|
||||
private String destinationPort;
|
||||
private String protocol;
|
||||
private Integer protocolNum;
|
||||
|
||||
private String maskSourceIP;
|
||||
private String maskSourcePort;
|
||||
private String maskDestinationIP;
|
||||
private String maskDestinationPort;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class Task {
|
||||
@JsonProperty("task_id")
|
||||
private Integer taskId;
|
||||
private Long taskId;
|
||||
|
||||
@JsonProperty("task_name")
|
||||
@NotNull(message = "task_name should not be empty. ")
|
||||
@@ -19,6 +19,7 @@ public class Task {
|
||||
|
||||
@JsonProperty("task_start_time")
|
||||
@NotNull(message = "task_start_time should not be empty. ")
|
||||
@Future(message = "task_start_time should be a future time")
|
||||
private LocalDateTime taskStartTime;
|
||||
|
||||
@JsonProperty("task_end_time")
|
||||
@@ -34,7 +35,7 @@ public class Task {
|
||||
|
||||
@JsonProperty("task_type")
|
||||
@NotNull(message = "task_type should not be empty. ")
|
||||
private String taskType;
|
||||
private Integer taskType;
|
||||
|
||||
@JsonProperty("task_act")
|
||||
@NotNull(message = "task_act should not be empty. ")
|
||||
@@ -47,13 +48,13 @@ public class Task {
|
||||
private String taskCreateDepart;
|
||||
|
||||
@JsonProperty("task_create_userid")
|
||||
private Integer taskCreateUserId;
|
||||
private Long taskCreateUserId;
|
||||
|
||||
@JsonProperty("static_rule_ids")
|
||||
private List<Integer> staticRuleIds;
|
||||
private List<Long> staticRuleIds;
|
||||
|
||||
@JsonProperty("dynamic_rule_ids")
|
||||
private List<Integer> dynamicRuleIds;
|
||||
private List<Long> dynamicRuleIds;
|
||||
|
||||
@JsonProperty("task_status")
|
||||
private Integer taskStatus;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.realtime.protection.configuration.entity.task;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class TaskCommandInfo {
|
||||
private FiveTupleWithMask fiveTupleWithMask;
|
||||
|
||||
private Long taskId;
|
||||
private Long ruleId;
|
||||
|
||||
// 额外字段
|
||||
private String operation;
|
||||
private Integer frequency;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
}
|
||||
Reference in New Issue
Block a user