1、告警信息增加备注接口
2、task下查询所有配置、任务、规则的未审批数量接口
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
package com.realtime.protection.server.alertmessage;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.realtime.protection.configuration.entity.alert.AlertMessage;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import jakarta.validation.Valid;
|
||||
import jdk.jfr.DataAmount;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("alertmessage")
|
||||
@Slf4j
|
||||
@@ -30,4 +36,23 @@ public class AlertMessageController
|
||||
.setData("alarms", alertMessageService.queryAlarmsByCommandId(commandId));
|
||||
}
|
||||
|
||||
@Data
|
||||
class AlertMessageAuditInfo {
|
||||
@JsonProperty("id")
|
||||
private Integer id;
|
||||
@JsonProperty("audit_info")
|
||||
private String auditInfo;
|
||||
}
|
||||
//告警信息审计接口
|
||||
@PostMapping("/auditInfo/{id}")
|
||||
public ResponseResult updateAuditInfo(@PathVariable String id,
|
||||
@RequestBody Map<String, String> auditInfo) {
|
||||
if (auditInfo.get("auditInfo") == null || auditInfo.get("auditInfo").isEmpty()) {
|
||||
return ResponseResult.ok();
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.setData("success", alertMessageService.updateAuditInfo(id, auditInfo.get("auditInfo")));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,6 @@ public interface AlertMessageMapper {
|
||||
void insertAlertMessage(AlertMessage alertMessage);
|
||||
@DS("doris")
|
||||
List<AlertMessage> queryAlermsByCommandId(String commandId);
|
||||
@DS("doris")
|
||||
Boolean updateAuditInfo(String id, String auditInfo);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,18 @@ public class AlertMessageService {
|
||||
private final Counter counter;
|
||||
private final StateHandler stateHandler;
|
||||
|
||||
public AlertMessageService(
|
||||
CommandService commandService, AlertMessageMapper alertMessageMapper, Counter counter, StateHandler stateHandler) {
|
||||
public AlertMessageService(CommandService commandService, AlertMessageMapper alertMessageMapper,
|
||||
Counter counter, StateHandler stateHandler) {
|
||||
this.commandService = commandService;
|
||||
this.alertMessageMapper = alertMessageMapper;
|
||||
this.counter = counter;
|
||||
this.stateHandler = stateHandler;
|
||||
}
|
||||
|
||||
public Boolean updateAuditInfo(String id, String auditInfo) {
|
||||
return alertMessageMapper.updateAuditInfo(id, auditInfo);
|
||||
}
|
||||
|
||||
@DSTransactional
|
||||
public void processAlertMessage(AlertMessage alertMessage) {
|
||||
//将告警信息中的c_time转换为LocalDateTime,并写入ctime
|
||||
|
||||
@@ -23,7 +23,7 @@ public interface CommandMapper {
|
||||
Boolean startCommandsByTaskId(@Param("task_id") Long taskId);
|
||||
|
||||
Boolean setCommandJudged(@Param("command_id") String commandId,
|
||||
@Param("is_judged") Boolean isJudged);
|
||||
@Param("is_judged") Integer isJudged);
|
||||
|
||||
List<TaskCommandInfo> queryCommandInfos(@Param("task_id") Long taskId,
|
||||
@Param("src_ip") String sourceIP,
|
||||
|
||||
@@ -136,13 +136,13 @@ public class CommandService {
|
||||
return commandMapper.removeCommandsByTaskId(taskId);
|
||||
}
|
||||
|
||||
public Boolean setCommandJudged(String commandId, Boolean isJudged) {
|
||||
public Boolean setCommandJudged(String commandId, Integer isJudged) {
|
||||
//设置指令是否已经研判
|
||||
Boolean success = commandMapper.setCommandJudged(commandId, isJudged);
|
||||
|
||||
try {
|
||||
List<String> commandUUIDs = Collections.singletonList(commandId);
|
||||
if (!isJudged) {
|
||||
if (isJudged != 1) {
|
||||
return success;
|
||||
}
|
||||
//指令首次下发
|
||||
|
||||
@@ -8,7 +8,12 @@ import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import com.realtime.protection.configuration.utils.enums.StateEnum;
|
||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||
import com.realtime.protection.server.command.CommandService;
|
||||
import com.realtime.protection.server.defense.object.ProtectObjectService;
|
||||
import com.realtime.protection.server.defense.templatenew.TemplateService;
|
||||
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleService;
|
||||
import com.realtime.protection.server.rule.staticrule.StaticRuleService;
|
||||
import com.realtime.protection.server.task.status.StateChangeService;
|
||||
import com.realtime.protection.server.whitelist.WhiteListService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -28,11 +33,22 @@ import java.util.Map;
|
||||
public class TaskController implements TaskControllerApi {
|
||||
|
||||
private final TaskService taskService;
|
||||
private final StaticRuleService staticRuleService;
|
||||
private final DynamicRuleService dynamicRuleService;
|
||||
private final ProtectObjectService protectObjectService;
|
||||
private final WhiteListService whiteListService;
|
||||
private final TemplateService templateService;
|
||||
|
||||
private final CommandService commandService;
|
||||
private final StateChangeService stateChangeService;
|
||||
|
||||
public TaskController(TaskService taskService, CommandService commandService, StateChangeService stateChangeService) {
|
||||
public TaskController(TaskService taskService, StaticRuleService staticRuleService, DynamicRuleService dynamicRuleService, ProtectObjectService protectObjectService, WhiteListService whiteListService, TemplateService templateService, CommandService commandService, StateChangeService stateChangeService) {
|
||||
this.taskService = taskService;
|
||||
this.staticRuleService = staticRuleService;
|
||||
this.dynamicRuleService = dynamicRuleService;
|
||||
this.protectObjectService = protectObjectService;
|
||||
this.whiteListService = whiteListService;
|
||||
this.templateService = templateService;
|
||||
this.commandService = commandService;
|
||||
this.stateChangeService = stateChangeService;
|
||||
}
|
||||
@@ -204,7 +220,7 @@ public class TaskController implements TaskControllerApi {
|
||||
}
|
||||
|
||||
@GetMapping("/{commandId}/valid/{isJudged}")
|
||||
public ResponseResult setCommandJudged(@PathVariable Boolean isJudged,
|
||||
public ResponseResult setCommandJudged(@PathVariable Integer isJudged,
|
||||
@PathVariable String commandId) {
|
||||
return ResponseResult.ok()
|
||||
.setData("success", commandService.setCommandJudged(commandId, isJudged))
|
||||
@@ -297,5 +313,20 @@ public class TaskController implements TaskControllerApi {
|
||||
.setData("history", taskService.queryHistory(id, page, pageSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/unaudit/statistics")
|
||||
public ResponseResult queryUnauditStatistics() {
|
||||
return ResponseResult.ok()
|
||||
.setData("task", taskService.queryAuditTaskTotalNum(AuditStatusEnum.PENDING.getNum()))
|
||||
.setData("static_rule", staticRuleService.queryAuditStaticRuleTotalNum(AuditStatusEnum.PENDING.getNum()))
|
||||
.setData("dynamic_rule", dynamicRuleService.queryAuditDynamicRuleTotalNum(AuditStatusEnum.PENDING.getNum()))
|
||||
.setData("proobj_undit_num", protectObjectService.queryProtectObjectsTotalNum(null, null, null, null,
|
||||
null, null, null, null, null,
|
||||
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())))
|
||||
.setData("white_list", whiteListService.queryAuditWhiteListTotalNum(AuditStatusEnum.PENDING.getNum()))
|
||||
.setData("strategy_template", templateService.queryAuditTemplateTotalNum(AuditStatusEnum.PENDING.getNum()))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -544,7 +544,7 @@ public interface TaskControllerApi {
|
||||
)
|
||||
)
|
||||
@GetMapping("/{commandId}/valid/{isJudged}")
|
||||
ResponseResult setCommandJudged(@PathVariable Boolean isJudged,
|
||||
ResponseResult setCommandJudged(@PathVariable Integer isJudged,
|
||||
@PathVariable String commandId);
|
||||
|
||||
@Operation(
|
||||
@@ -693,4 +693,21 @@ public interface TaskControllerApi {
|
||||
ResponseResult queryHistory(@PathVariable Long id,
|
||||
@RequestParam(value = "page", required = true) Integer page,
|
||||
@RequestParam(value = "page_size", required = true) Integer pageSize);
|
||||
@Operation(
|
||||
summary = "查询规则、任务、配置的未审核数量",
|
||||
description = "查询规则、任务、配置的未审核数量",
|
||||
responses = {
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(
|
||||
description = "返回是否成功",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
)
|
||||
)
|
||||
},
|
||||
parameters = {
|
||||
}
|
||||
)
|
||||
@GetMapping("/unaudit/statistics")
|
||||
ResponseResult queryUnauditStatistics();
|
||||
}
|
||||
|
||||
@@ -177,6 +177,11 @@
|
||||
)
|
||||
|
||||
</insert>
|
||||
<update id="updateAuditInfo">
|
||||
UPDATE t_alertmessage
|
||||
SET audit_info = #{auditInfo}
|
||||
WHERE ALERT_MESSAGE_ID = #{id}
|
||||
</update>
|
||||
|
||||
<!-- <select id="queryTemplateProtectLevel" resultMap="protectLevelMap">-->
|
||||
<!-- SELECT-->
|
||||
|
||||
Reference in New Issue
Block a user