1、动态规则:新增批量审核、统计接口。修改query动态规则不查询auditstatus
2、静态规则:新增批量审核、统计接口。 3、任务:新增批量审核、统计接口。 4、白名单:新增统计接口、 5、防护对象:新增统计接口 6、策略模板:新增统计接口
This commit is contained in:
@@ -3,6 +3,7 @@ package com.realtime.protection.server.defense.object;
|
|||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||||
import com.realtime.protection.configuration.response.ResponseResult;
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
@@ -149,4 +150,22 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
|||||||
.addDataMap(protectObjectService.changeProtectObjectAuditStatus(protectObjectId, auditStatus))
|
.addDataMap(protectObjectService.changeProtectObjectAuditStatus(protectObjectId, auditStatus))
|
||||||
.setData("proobj_id", protectObjectId);
|
.setData("proobj_id", protectObjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
防护对象数据统计
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public ResponseResult statisticsProtectObject() {
|
||||||
|
return ResponseResult.ok()
|
||||||
|
.setData("proobj_num", protectObjectService.queryProtectObjectsTotalNum(null, null, null, null,
|
||||||
|
null, null, null, null, null, null))
|
||||||
|
.setData("proobj_used_num", protectObjectService.queryUsedProtectObjectsTotalNum())
|
||||||
|
.setData("proobj_audit_num", protectObjectService.queryProtectObjectsTotalNum(null, null, null, null,
|
||||||
|
null, null, null, null, null,
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.AUDITED.getState())))
|
||||||
|
.setData("proobj_undit_num", protectObjectService.queryProtectObjectsTotalNum(null, null, null, null,
|
||||||
|
null, null, null, null, null,
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,4 +408,41 @@ public interface ProtectObjectControllerApi {
|
|||||||
)
|
)
|
||||||
ResponseResult changeProtectObjectAuditStatus(@PathVariable Integer protectObjectId,
|
ResponseResult changeProtectObjectAuditStatus(@PathVariable Integer protectObjectId,
|
||||||
@PathVariable Integer auditStatus);
|
@PathVariable Integer auditStatus);
|
||||||
|
|
||||||
|
/*
|
||||||
|
防护对象数据统计
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "数据统计",
|
||||||
|
description = "数据统计",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
description = "返回数据统计",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "example",
|
||||||
|
value = """
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"message": "request succeed",
|
||||||
|
"data": {
|
||||||
|
"proobj_num": 2,
|
||||||
|
"proobj_used_num": 2,
|
||||||
|
"proobj_audit_num": 1,
|
||||||
|
"proobj_undit_num": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
ResponseResult statisticsProtectObject();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.realtime.protection.server.defense.object;
|
package com.realtime.protection.server.defense.object;
|
||||||
|
|
||||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||||
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@@ -48,4 +49,6 @@ public interface ProtectObjectMapper {
|
|||||||
@Param("proobj_audit_status") Integer protectObjectAuditStatus,
|
@Param("proobj_audit_status") Integer protectObjectAuditStatus,
|
||||||
@Param("page") Integer page,
|
@Param("page") Integer page,
|
||||||
@Param("page_size") Integer pageSize);
|
@Param("page_size") Integer pageSize);
|
||||||
|
|
||||||
|
Integer queryUsedProtectObjectsTotalNum();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.realtime.protection.server.defense.object;
|
|||||||
|
|
||||||
import com.alibaba.excel.util.ListUtils;
|
import com.alibaba.excel.util.ListUtils;
|
||||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||||
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
|
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
|
||||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
|
||||||
@@ -142,4 +143,8 @@ public class ProtectObjectService {
|
|||||||
protectObjectCreateUsername, protectObjectAuditStatus
|
protectObjectCreateUsername, protectObjectAuditStatus
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer queryUsedProtectObjectsTotalNum() {
|
||||||
|
return protectObjectMapper.queryUsedProtectObjectsTotalNum();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.realtime.protection.server.defense.template;
|
|||||||
|
|
||||||
import com.realtime.protection.configuration.entity.defense.template.Template;
|
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||||
import com.realtime.protection.configuration.response.ResponseResult;
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -112,5 +113,20 @@ public class TemplateController implements TemplateControllerApi {
|
|||||||
.setData("template_id", templateService.queryTemplateId(sourceSystem, eventName));
|
.setData("template_id", templateService.queryTemplateId(sourceSystem, eventName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
策略模板数据统计
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public ResponseResult statisticsTemplate() {
|
||||||
|
return ResponseResult.ok()
|
||||||
|
.setData("template_num", templateService.queryTemplateTotalNum(null, null, null))
|
||||||
|
.setData("template_used_num", templateService.queryUsedTemplateTotalNum())
|
||||||
|
.setData("template_audit_num", templateService.queryAuditTemplateTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.AUDITED.getState())
|
||||||
|
))
|
||||||
|
.setData("template_unaudit_num", templateService.queryAuditTemplateTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -438,4 +438,41 @@ public interface TemplateControllerApi {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult queryTemplateId(@RequestBody Map<String, String> map);
|
ResponseResult queryTemplateId(@RequestBody Map<String, String> map);
|
||||||
|
|
||||||
|
/*
|
||||||
|
策略模板数据统计
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "数据统计",
|
||||||
|
description = "数据统计",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
description = "返回数据统计",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "example",
|
||||||
|
value = """
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"message": "request succeed",
|
||||||
|
"data": {
|
||||||
|
"template_num": 1,
|
||||||
|
"template_used_num": 1,
|
||||||
|
"template_audit_num": 0,
|
||||||
|
"template_unaudit_num": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
ResponseResult statisticsTemplate();
|
||||||
}
|
}
|
||||||
@@ -38,4 +38,8 @@ public interface TemplateMapper {
|
|||||||
List<String> queryEventName(String sourceSystem);
|
List<String> queryEventName(String sourceSystem);
|
||||||
|
|
||||||
Integer queryTemplateId(String sourceSystem, String eventName);
|
Integer queryTemplateId(String sourceSystem, String eventName);
|
||||||
|
|
||||||
|
Integer queryUsedTemplateTotalNum();
|
||||||
|
|
||||||
|
Integer queryAuditTemplateTotalNum(Integer auditState);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,4 +79,12 @@ public class TemplateService {
|
|||||||
public Integer queryTemplateId(String sourceSystem, String eventName) {
|
public Integer queryTemplateId(String sourceSystem, String eventName) {
|
||||||
return templateMapper.queryTemplateId(sourceSystem, eventName);
|
return templateMapper.queryTemplateId(sourceSystem, eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer queryUsedTemplateTotalNum() {
|
||||||
|
return templateMapper.queryUsedTemplateTotalNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer queryAuditTemplateTotalNum(Integer auditState) {
|
||||||
|
return templateMapper.queryAuditTemplateTotalNum(auditState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.realtime.protection.server.rule.dynamicrule;
|
|||||||
|
|
||||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||||
import com.realtime.protection.configuration.response.ResponseResult;
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -164,15 +165,22 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
|||||||
/**
|
/**
|
||||||
* 获取统计数据
|
* 获取统计数据
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@GetMapping("/statistics")
|
@GetMapping("/statistics")
|
||||||
public ResponseResult getStaticRuleStatisticsData(){
|
public ResponseResult getStaticRuleStatisticsData(){
|
||||||
|
|
||||||
return ResponseResult.ok()
|
return ResponseResult.ok()
|
||||||
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null, null,
|
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null, null,
|
||||||
null, null))
|
null, null))
|
||||||
.setData("dynamic_rule_used_num", dynamicRuleService.queryUsedDynamicRuleTotalNum())
|
.setData("dynamic_rule_used_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(
|
||||||
.setData("dynamic_rule_audit_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(1))
|
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
|
||||||
.setData("dynamic_rule_unaudit_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(0));
|
))
|
||||||
|
.setData("dynamic_rule_audit_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.AUDITED.getState())
|
||||||
|
))
|
||||||
|
.setData("dynamic_rule_unaudit_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -358,5 +358,37 @@ public interface DynamicRuleControllerApi {
|
|||||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);
|
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "数据统计",
|
||||||
|
description = "数据统计",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
description = "返回数据统计",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "example",
|
||||||
|
value = """
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"message": "request succeed",
|
||||||
|
"data": {
|
||||||
|
"dynamic_rule_num": 3,
|
||||||
|
"dynamic_rule_used_num": 0,
|
||||||
|
"dynamic_rule_audit_num": 2,
|
||||||
|
"dynamic_rule_unaudit_num": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
ResponseResult getStaticRuleStatisticsData();
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ package com.realtime.protection.server.rule.staticrule;
|
|||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
||||||
import com.realtime.protection.configuration.response.ResponseResult;
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
@@ -178,6 +179,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
/**
|
/**
|
||||||
* 批量修改审核状态
|
* 批量修改审核状态
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@PostMapping("/auditbatch")
|
@PostMapping("/auditbatch")
|
||||||
public ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
public ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||||
List<Integer> errorIds = new ArrayList<>();
|
List<Integer> errorIds = new ArrayList<>();
|
||||||
@@ -198,6 +200,26 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
.setData("success", staticRuleService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
.setData("success", staticRuleService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取统计数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public ResponseResult getStaticRuleStatisticsData(){
|
||||||
|
|
||||||
|
return ResponseResult.ok()
|
||||||
|
.setData("static_rule_num", staticRuleService.queryStaticRuleTotalNum(null, null, null, null))
|
||||||
|
.setData("static_rule_used_num", staticRuleService.queryAuditStaticRuleTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
|
||||||
|
))
|
||||||
|
.setData("static_rule_audit_num", staticRuleService.queryAuditStaticRuleTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.AUDITED.getState())
|
||||||
|
))
|
||||||
|
.setData("static_rule_unaudit_num", staticRuleService.queryAuditStaticRuleTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,17 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Tag(name = "静态规则API", description = "静态规则模块所有接口")
|
@Tag(name = "静态规则API", description = "静态规则模块所有接口")
|
||||||
public interface StaticRuleControllerApi {
|
public interface StaticRuleControllerApi {
|
||||||
@@ -281,4 +280,62 @@ public interface StaticRuleControllerApi {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus);
|
ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus);
|
||||||
|
|
||||||
|
@PostMapping("/auditbatch")
|
||||||
|
@Operation(
|
||||||
|
summary = "批量更新静态规则审批状态",
|
||||||
|
description = "批量更新静态规则审批状态,0未审核、1审核不通过、2审核通过",
|
||||||
|
responses = {
|
||||||
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(
|
||||||
|
description = "返回静态规则审核结果",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||||
|
description = "字典,key是静态规则id,value是静态规则审核状态id",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = Map.class)
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ResponseResult updateStaticRuleAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap);
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "数据统计",
|
||||||
|
description = "数据统计",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
description = "返回数据统计",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "example",
|
||||||
|
value = """
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"message": "request succeed",
|
||||||
|
"data": {
|
||||||
|
"static_rule_num": 7,
|
||||||
|
"static_rule_used_num": 2,
|
||||||
|
"static_rule_audit_num": 3,
|
||||||
|
"static_rule_unaudit_num": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
ResponseResult getStaticRuleStatisticsData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,4 +46,8 @@ public interface StaticRuleMapper {
|
|||||||
List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids);
|
List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids);
|
||||||
|
|
||||||
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch")Map<Integer, Integer> idWithAuditStatusBatch);
|
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch")Map<Integer, Integer> idWithAuditStatusBatch);
|
||||||
|
|
||||||
|
Integer queryUsedStaticRuleTotalNum();
|
||||||
|
|
||||||
|
Integer queryAuditStaticRuleTotalNum(@Param("auditStatus")Integer auditStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,13 +193,13 @@ public class StaticRuleService {
|
|||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteStaticRuleById(Integer id) {
|
public void deleteStaticRuleById(Integer id) {
|
||||||
StaticRuleObject staticRuleObject = staticRuleMapper.queryStaticRuleById(id);
|
StaticRuleObject staticRuleObject = staticRuleMapper.queryStaticRuleById(id);
|
||||||
if (staticRuleObject == null) {
|
if (staticRuleObject == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.equals(staticRuleObject.getAuditStatus(), AuditStatusEnum.USING.getNum())) {
|
if (Objects.equals(staticRuleObject.getAuditStatus(), AuditStatusEnum.USING.getNum())) {
|
||||||
throw new IllegalArgumentException("当前静态规则正在使用,无法删除");
|
throw new IllegalArgumentException("当前静态规则正在使用,无法删除");
|
||||||
}
|
}
|
||||||
@@ -242,4 +242,12 @@ public class StaticRuleService {
|
|||||||
//实现事务操作
|
//实现事务操作
|
||||||
return sqlSessionWrapper.startBatchSession(StaticRuleMapper.class, updateStaticRuleAuditStatusFunction, idsWithAuditStatusMap);
|
return sqlSessionWrapper.startBatchSession(StaticRuleMapper.class, updateStaticRuleAuditStatusFunction, idsWithAuditStatusMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer queryUsedStaticRuleTotalNum() {
|
||||||
|
return staticRuleMapper.queryUsedStaticRuleTotalNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer queryAuditStaticRuleTotalNum(Integer auditStatus) {
|
||||||
|
return staticRuleMapper.queryAuditStaticRuleTotalNum(auditStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.realtime.protection.configuration.entity.task.Task;
|
|||||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||||
import com.realtime.protection.configuration.exception.DorisStartException;
|
import com.realtime.protection.configuration.exception.DorisStartException;
|
||||||
import com.realtime.protection.configuration.response.ResponseResult;
|
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.command.CommandService;
|
||||||
import com.realtime.protection.server.task.status.StateChangeService;
|
import com.realtime.protection.server.task.status.StateChangeService;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -162,6 +164,7 @@ public class TaskController implements TaskControllerApi {
|
|||||||
/**
|
/**
|
||||||
* 批量修改审核状态
|
* 批量修改审核状态
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@PostMapping("/auditbatch")
|
@PostMapping("/auditbatch")
|
||||||
public ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
public ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||||
List<Integer> errorIds = new ArrayList<>();
|
List<Integer> errorIds = new ArrayList<>();
|
||||||
@@ -181,4 +184,20 @@ public class TaskController implements TaskControllerApi {
|
|||||||
return ResponseResult.ok()
|
return ResponseResult.ok()
|
||||||
.setData("success", taskService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
.setData("success", taskService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public ResponseResult statistics() {
|
||||||
|
return ResponseResult.ok()
|
||||||
|
.setData("total_num", taskService.queryTaskTotalNum(null, null, null, null))
|
||||||
|
.setData("running_num", taskService.queryTaskTotalNum(StateEnum.RUNNING.getStateNum(), null, null, null))
|
||||||
|
.setData("finished_num", taskService.queryTaskTotalNum(StateEnum.FINISHED.getStateNum(), null, null, null))
|
||||||
|
.setData("unaudit_num", taskService.queryAuditTaskTotalNum(
|
||||||
|
AuditStatusEnum.PENDING.getNum()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ import jakarta.validation.constraints.Min;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Tag(name = "任务控制器API", description = "任务管理模块相关的所有接口")
|
@Tag(name = "任务控制器API", description = "任务管理模块相关的所有接口")
|
||||||
public interface TaskControllerApi {
|
public interface TaskControllerApi {
|
||||||
@PostMapping("/new")
|
@PostMapping("/new")
|
||||||
@@ -521,4 +523,71 @@ public interface TaskControllerApi {
|
|||||||
@GetMapping("/{commandId}/valid/{isJudged}")
|
@GetMapping("/{commandId}/valid/{isJudged}")
|
||||||
ResponseResult setCommandJudged(@PathVariable Boolean isJudged,
|
ResponseResult setCommandJudged(@PathVariable Boolean isJudged,
|
||||||
@PathVariable String commandId);
|
@PathVariable String commandId);
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "批量更新任务审批状态",
|
||||||
|
description = "批量更新任务审批状态,0未审核、1审核不通过、2审核通过",
|
||||||
|
responses = {
|
||||||
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(
|
||||||
|
description = "返回任务审核结果",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||||
|
description = "字典,key是任务id,value是任务审核状态id",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = Map.class)
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@PostMapping("/auditbatch")
|
||||||
|
ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap);
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "数据统计",
|
||||||
|
description = "数据统计",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
description = "返回数据统计",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "example",
|
||||||
|
value = """
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"message": "request succeed",
|
||||||
|
"data": {
|
||||||
|
"total_num": 11,
|
||||||
|
"running_num": 2,
|
||||||
|
"finished_num": 5,
|
||||||
|
"unaudit_num": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""",
|
||||||
|
description = """
|
||||||
|
"total_num": 总数
|
||||||
|
|
||||||
|
"running_num": 运行任务数
|
||||||
|
|
||||||
|
"finished_num": 结束任务数
|
||||||
|
|
||||||
|
"unaudit_num": 未审核数
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
ResponseResult statistics();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,6 @@ public interface TaskMapper {
|
|||||||
@Param("task_name") String taskName, @Param("task_creator") String taskCreator);
|
@Param("task_name") String taskName, @Param("task_creator") String taskCreator);
|
||||||
|
|
||||||
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
|
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
|
||||||
|
|
||||||
|
Integer queryAuditTaskTotalNum(Integer auditState);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,4 +334,8 @@ public class TaskService {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer queryAuditTaskTotalNum(Integer auditState) {
|
||||||
|
return taskMapper.queryAuditTaskTotalNum(auditState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.realtime.protection.server.whitelist;
|
|||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.realtime.protection.configuration.entity.whitelist.WhiteListObject;
|
import com.realtime.protection.configuration.entity.whitelist.WhiteListObject;
|
||||||
import com.realtime.protection.configuration.response.ResponseResult;
|
import com.realtime.protection.configuration.response.ResponseResult;
|
||||||
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -194,5 +195,21 @@ public class WhiteListController implements WhiteListControllerApi {
|
|||||||
.setData("whiteobj_list", whiteListService.whiteListStaticRulesCheck(staticRuleIds));
|
.setData("whiteobj_list", whiteListService.whiteListStaticRulesCheck(staticRuleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
白名单数据统计
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public ResponseResult getWhiteListStatisticsData() {
|
||||||
|
return ResponseResult.ok()
|
||||||
|
.setData("whiteobj_num", whiteListService.queryWhiteListTotalNum(null, null))
|
||||||
|
.setData("whiteobj_audit_num", whiteListService.queryAuditWhiteListTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.AUDITED.getState())
|
||||||
|
))
|
||||||
|
.setData("whiteobj_unaudit_num", whiteListService.queryAuditWhiteListTotalNum(
|
||||||
|
AuditStatusEnum.getNumByState(AuditStatusEnum.PENDING.getState())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@@ -240,4 +242,51 @@ public interface WhiteListControllerApi {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult whiteListStaticRulesCheck(@PathVariable List<Integer> staticRuleIds);
|
ResponseResult whiteListStaticRulesCheck(@PathVariable List<Integer> staticRuleIds);
|
||||||
|
|
||||||
|
/*
|
||||||
|
白名单数据统计
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "白名单数据统计",
|
||||||
|
description = "白名单数据统计",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(
|
||||||
|
description = "返回白名单数据统计",
|
||||||
|
content = @Content(
|
||||||
|
mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = ResponseResult.class),
|
||||||
|
examples = @ExampleObject(
|
||||||
|
name = "example",
|
||||||
|
value = """
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"message": "request succeed",
|
||||||
|
"data": {
|
||||||
|
"proobj_num": 2,
|
||||||
|
"proobj_used_num": 2,
|
||||||
|
"proobj_audit_num": 1,
|
||||||
|
"proobj_undit_num": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""",
|
||||||
|
description = """
|
||||||
|
"proobj_num": 白名单总数
|
||||||
|
|
||||||
|
"template_name": 白名单使用数
|
||||||
|
|
||||||
|
"proobj_audit_num": 审核通过数
|
||||||
|
|
||||||
|
"proobj_undit_num": 未审核数
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
ResponseResult getWhiteListStatisticsData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ public interface WhiteListMapper {
|
|||||||
List<WhiteListObject> whiteListCommandsCheck(List<TaskCommandInfo> taskCommandInfos);
|
List<WhiteListObject> whiteListCommandsCheck(List<TaskCommandInfo> taskCommandInfos);
|
||||||
|
|
||||||
List<WhiteListObject> whiteListCStaticRulesCheck(@Param("staticRuleObjects") List<StaticRuleObject> staticRuleObjects);
|
List<WhiteListObject> whiteListCStaticRulesCheck(@Param("staticRuleObjects") List<StaticRuleObject> staticRuleObjects);
|
||||||
|
|
||||||
|
Integer queryAuditWhiteListTotalNum(@Param("auditStatus") Integer auditStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,4 +185,7 @@ public class WhiteListService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer queryAuditWhiteListTotalNum(Integer auditStatus) {
|
||||||
|
return whiteListMapper.queryAuditWhiteListTotalNum(auditStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,7 @@
|
|||||||
<!-- <result column="protect_object_id" property="protectObjectIds"/>-->
|
<!-- <result column="protect_object_id" property="protectObjectIds"/>-->
|
||||||
<result column="strategy_template_name" property="dynamicRuleEventType"/>
|
<result column="strategy_template_name" property="dynamicRuleEventType"/>
|
||||||
<result column="strategy_template_source_system" property="dynamicRuleSourceSystem"/>
|
<result column="strategy_template_source_system" property="dynamicRuleSourceSystem"/>
|
||||||
|
<result column="audit_status" property="auditStatus"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryDynamicRuleById" resultMap="dynamicRuleMap">
|
<select id="queryDynamicRuleById" resultMap="dynamicRuleMap">
|
||||||
@@ -272,7 +273,9 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
<select id="queryAuditDynamicRuleTotalNum" resultType="java.lang.Integer">
|
<select id="queryAuditDynamicRuleTotalNum" resultType="java.lang.Integer">
|
||||||
|
select count(*)
|
||||||
|
from t_dynamic_rule
|
||||||
|
where audit_status = #{auditStatus}
|
||||||
</select>
|
</select>
|
||||||
<select id="queryAuditStatusById" resultType="java.lang.Integer">
|
<select id="queryAuditStatusById" resultType="java.lang.Integer">
|
||||||
select audit_status
|
select audit_status
|
||||||
|
|||||||
@@ -132,6 +132,11 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="queryUsedProtectObjectsTotalNum"
|
||||||
|
resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(DISTINCT protect_object_id)
|
||||||
|
FROM t_protect_object_dynamic_rule_conn
|
||||||
|
</select>
|
||||||
|
|
||||||
<update id="updateProtectObject">
|
<update id="updateProtectObject">
|
||||||
UPDATE t_protect_object
|
UPDATE t_protect_object
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#{object.staticRuleMdport}, #{object.staticRuleProtocol}, #{object.staticRuleMprotocol},
|
#{object.staticRuleMdport}, #{object.staticRuleProtocol}, #{object.staticRuleMprotocol},
|
||||||
#{object.staticRuleDns}, #{object.staticRuleURL}, #{object.staticRulePriority},
|
#{object.staticRuleDns}, #{object.staticRuleURL}, #{object.staticRulePriority},
|
||||||
#{object.staticRuleRange}, #{object.staticRuleFrequency},
|
#{object.staticRuleRange}, #{object.staticRuleFrequency},
|
||||||
#{object.staticRuleAuditStatus})
|
#{object.auditStatus})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="newStaticRules">
|
<insert id="newStaticRules">
|
||||||
insert into t_static_rule(static_rule_name, static_rule_create_time,
|
insert into t_static_rule(static_rule_name, static_rule_create_time,
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
<result column="static_rule_create_depart" property="staticRuleCreateDepart"/>
|
<result column="static_rule_create_depart" property="staticRuleCreateDepart"/>
|
||||||
<result column="static_rule_used_task_id" property="staticRuleUsedTaskId"/>
|
<result column="static_rule_used_task_id" property="staticRuleUsedTaskId"/>
|
||||||
<result column="task_status" property="usedTaskStatus"/>
|
<result column="task_status" property="usedTaskStatus"/>
|
||||||
<result column="static_rule_audit_status" property="staticRuleAuditStatus"/>
|
<result column="static_rule_audit_status" property="auditStatus"/>
|
||||||
<result column="static_rule_create_user_id" property="staticRuleCreateUserId"/>
|
<result column="static_rule_create_user_id" property="staticRuleCreateUserId"/>
|
||||||
<result column="static_rule_modify_time" property="staticRuleModifyTime"/>
|
<result column="static_rule_modify_time" property="staticRuleModifyTime"/>
|
||||||
|
|
||||||
@@ -206,5 +206,15 @@
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="queryUsedStaticRuleTotalNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM t_static_rule
|
||||||
|
WHERE static_rule_used_task_id IS NOT NULL;
|
||||||
|
</select>
|
||||||
|
<select id="queryAuditStaticRuleTotalNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM t_static_rule
|
||||||
|
WHERE static_rule_audit_status = #{auditStatus}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -257,7 +257,7 @@
|
|||||||
<result column="log_rule_id" property="logRuleId"/>
|
<result column="log_rule_id" property="logRuleId"/>
|
||||||
<result column="source_system" property="sourceSystem"/>
|
<result column="source_system" property="sourceSystem"/>
|
||||||
<result column="event_type" property="eventType"/>
|
<result column="event_type" property="eventType"/>
|
||||||
<collection property="protectObjects">
|
<collection property="protectObjects" ofType="com.realtime.protection.configuration.entity.task.DynamicTaskInfo$SimpleProtectObject">
|
||||||
<result column="protect_object_ip" property="IP"/>
|
<result column="protect_object_ip" property="IP"/>
|
||||||
<result column="protect_object_port" property="port"/>
|
<result column="protect_object_port" property="port"/>
|
||||||
<result column="protect_object_url" property="URL"/>
|
<result column="protect_object_url" property="URL"/>
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="getDynamicTaskInfos"
|
<select id="getDynamicTaskInfos"
|
||||||
resultType="com.realtime.protection.configuration.entity.task.DynamicTaskInfo">
|
resultMap="dynamicTaskInfoMap">
|
||||||
SELECT task_id,
|
SELECT task_id,
|
||||||
task_start_time,
|
task_start_time,
|
||||||
task_end_time,
|
task_end_time,
|
||||||
@@ -274,7 +274,7 @@
|
|||||||
strategy_template_source_system as source_system,
|
strategy_template_source_system as source_system,
|
||||||
strategy_template_name as event_type,
|
strategy_template_name as event_type,
|
||||||
tdr.log_rule_id,
|
tdr.log_rule_id,
|
||||||
INET_NTOA(protect_object_ip),
|
INET_NTOA(protect_object_ip) as protect_object_ip,
|
||||||
protect_object_port,
|
protect_object_port,
|
||||||
protect_object_url,
|
protect_object_url,
|
||||||
protect_object_protocol
|
protect_object_protocol
|
||||||
@@ -304,4 +304,9 @@
|
|||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryAuditTaskTotalNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*) FROM t_task
|
||||||
|
WHERE task_audit_status = #{auditStatus}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -146,6 +146,17 @@
|
|||||||
WHERE strategy_template_name = #{eventName} AND strategy_template_source_system = #{sourceSystem}
|
WHERE strategy_template_name = #{eventName} AND strategy_template_source_system = #{sourceSystem}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryUsedTemplateTotalNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(DISTINCT template_id)
|
||||||
|
FROM t_dynamic_rule
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryAuditTemplateTotalNum" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM t_strategy_template
|
||||||
|
WHERE audit_state = #{auditState}
|
||||||
|
</select>
|
||||||
|
|
||||||
<update id="updateTemplateInformation">
|
<update id="updateTemplateInformation">
|
||||||
UPDATE t_strategy_template
|
UPDATE t_strategy_template
|
||||||
<set>
|
<set>
|
||||||
|
|||||||
@@ -284,5 +284,10 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="queryAuditWhiteListTotalNum" resultType="java.lang.Integer">
|
||||||
|
select COUNT(*)
|
||||||
|
from t_white_list
|
||||||
|
where white_list_audit_status = #{auditStatus}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -114,4 +114,6 @@ public class StaticRuleServiceTest extends ProtectionApplicationTests {
|
|||||||
System.out.println(staticRuleService.updateAuditStatusBatch(map));
|
System.out.println(staticRuleService.updateAuditStatusBatch(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package com.realtime.protection.server.task;
|
|||||||
import com.realtime.protection.ProtectionApplicationTests;
|
import com.realtime.protection.ProtectionApplicationTests;
|
||||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||||
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
||||||
|
import com.realtime.protection.configuration.entity.task.DynamicTaskInfo;
|
||||||
import com.realtime.protection.configuration.entity.task.Task;
|
import com.realtime.protection.configuration.entity.task.Task;
|
||||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||||
|
import com.realtime.protection.configuration.exception.DorisStartException;
|
||||||
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleService;
|
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleService;
|
||||||
import com.realtime.protection.server.rule.staticrule.StaticRuleService;
|
import com.realtime.protection.server.rule.staticrule.StaticRuleService;
|
||||||
import com.realtime.protection.server.task.status.StateChangeService;
|
import com.realtime.protection.server.task.status.StateChangeService;
|
||||||
@@ -27,13 +29,15 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
|||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
private final StaticRuleService staticRuleService;
|
private final StaticRuleService staticRuleService;
|
||||||
private final DynamicRuleService dynamicRuleService;
|
private final DynamicRuleService dynamicRuleService;
|
||||||
|
private final StateChangeService stateChangeService;
|
||||||
private Task task;
|
private Task task;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TaskServiceTest(TaskService taskService, StaticRuleService staticRuleService, DynamicRuleService dynamicRuleService) {
|
TaskServiceTest(TaskService taskService, StaticRuleService staticRuleService, DynamicRuleService dynamicRuleService, StateChangeService stateChangeService) {
|
||||||
this.taskService = taskService;
|
this.taskService = taskService;
|
||||||
this.staticRuleService = staticRuleService;
|
this.staticRuleService = staticRuleService;
|
||||||
this.dynamicRuleService = dynamicRuleService;
|
this.dynamicRuleService = dynamicRuleService;
|
||||||
|
this.stateChangeService = stateChangeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
@@ -189,4 +193,15 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
|||||||
|
|
||||||
System.out.println(taskService.updateAuditStatusBatch(map));
|
System.out.println(taskService.updateAuditStatusBatch(map));
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
void testGetDynamicTaskInfos(){
|
||||||
|
List<DynamicTaskInfo> dynamicTaskInfos = taskService.getDynamicTaskInfos(43844L);
|
||||||
|
System.out.println(dynamicTaskInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void changeTaskstatus() throws DorisStartException {
|
||||||
|
stateChangeService.changeState(2, 43844L, false);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user