1、增加AlertMessage http接口,接收告警信息,生成指令入库
2、staticrule优先级、频率限制范围
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.realtime.protection.configuration.entity.rule.dynamicrule;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.realtime.protection.configuration.entity.task.FiveTupleWithMask;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlertMessage {
|
||||
|
||||
@JsonProperty("task_id")
|
||||
private Long taskId;
|
||||
@JsonProperty("five_tuple_with_mask")
|
||||
private FiveTupleWithMask fiveTupleWithMask;
|
||||
|
||||
}
|
||||
@@ -128,7 +128,9 @@ public class StaticRuleObject {
|
||||
|
||||
@JsonProperty("static_rule_priority")
|
||||
@ExcelProperty("优先级")
|
||||
@Schema(description = "优先级", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Max(value = 3)
|
||||
@Min(value = 1)
|
||||
@Schema(description = "优先级,1代表高2代表中3代表低", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer staticRulePriority;
|
||||
@JsonProperty("static_rule_range")
|
||||
@ExcelProperty("范围")
|
||||
@@ -136,7 +138,8 @@ public class StaticRuleObject {
|
||||
private String staticRuleRange;
|
||||
@JsonProperty("static_rule_frequency")
|
||||
@ExcelProperty("频率")
|
||||
@Schema(description = "频率", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Min(value = 1)
|
||||
@Schema(description = "频率,最低为1", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer staticRuleFrequency;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.realtime.protection.server.alertmessage;
|
||||
|
||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.AlertMessage;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("alertmessage")
|
||||
@Slf4j
|
||||
public class AlertMessageController
|
||||
{
|
||||
private final AlertMessageService alertMessageService;
|
||||
public AlertMessageController(final AlertMessageService alertMessageService) {
|
||||
this.alertMessageService = alertMessageService;
|
||||
}
|
||||
|
||||
@PostMapping("/new")
|
||||
public ResponseResult receiveAlertMessage(@RequestBody @Valid AlertMessage alertMessage){
|
||||
alertMessageService.receiveAlertMessage(alertMessage);
|
||||
return ResponseResult.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.realtime.protection.server.alertmessage;
|
||||
|
||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.AlertMessage;
|
||||
import com.realtime.protection.configuration.entity.task.Task;
|
||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||
import com.realtime.protection.server.task.TaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.realtime.protection.server.command.CommandService;
|
||||
import com.realtime.protection.configuration.utils.enums.StateEnum;
|
||||
|
||||
@Service
|
||||
public class AlertMessageService {
|
||||
private final CommandService commandService;
|
||||
private final TaskService taskService;
|
||||
|
||||
public AlertMessageService(CommandService commandService,TaskService taskService) {
|
||||
this.commandService = commandService;
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
public void receiveAlertMessage(AlertMessage alertMessage) {
|
||||
Long taskId = alertMessage.getTaskId();
|
||||
//查task信息
|
||||
Task task = taskService.queryTask(taskId);
|
||||
//检查task status是否为running?
|
||||
// if (task.getTaskStatus() != StateEnum.RUNNING.getStateNum()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//task信息和alertMessage中的fiveTuple信息 合并成 TaskCommandInfo
|
||||
TaskCommandInfo dynamicTaskCommandInfo = new TaskCommandInfo();
|
||||
|
||||
|
||||
//command入库
|
||||
//commandService.createCommand(staticTaskCommandInfo);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user