diff --git a/src/main/java/com/realtime/protection/configuration/entity/defense/template/Template.java b/src/main/java/com/realtime/protection/configuration/entity/defense/template/Template.java index 8efd390..cb56048 100644 --- a/src/main/java/com/realtime/protection/configuration/entity/defense/template/Template.java +++ b/src/main/java/com/realtime/protection/configuration/entity/defense/template/Template.java @@ -77,6 +77,10 @@ public class Template { @Schema(description = "防御策略模板审核状态(0为未审核,1为已退回,2为审核通过)", example = "1", accessMode = Schema.AccessMode.READ_ONLY) private String auditStatus; + @JsonProperty("template_display_id") + @Schema(description = "策略模板展示id", accessMode = Schema.AccessMode.READ_ONLY) + private String templateDisplayId; + /** * 设置是否含有日常/应急/紧急防护等级态字段的字段 diff --git a/src/main/java/com/realtime/protection/configuration/entity/whitelist/WhiteListObject.java b/src/main/java/com/realtime/protection/configuration/entity/whitelist/WhiteListObject.java index 05dfe93..5fb5088 100644 --- a/src/main/java/com/realtime/protection/configuration/entity/whitelist/WhiteListObject.java +++ b/src/main/java/com/realtime/protection/configuration/entity/whitelist/WhiteListObject.java @@ -61,4 +61,10 @@ public class WhiteListObject { @ExcelIgnore @Schema(description = "白名单对象审核状态(0为未审核,1为已退回,2为审核通过)", example = "2") private Integer whiteListAuditStatus; + + @JsonProperty("white_list_display_id") + @ExcelIgnore + @Schema(description = "白名单展示id", example = "BMD-20200101-123456", accessMode = Schema.AccessMode.READ_ONLY) + private String whiteListDisplayId; + } diff --git a/src/main/java/com/realtime/protection/server/defense/template/TemplateService.java b/src/main/java/com/realtime/protection/server/defense/template/TemplateService.java index 3e8719c..a35de4f 100644 --- a/src/main/java/com/realtime/protection/server/defense/template/TemplateService.java +++ b/src/main/java/com/realtime/protection/server/defense/template/TemplateService.java @@ -1,11 +1,14 @@ package com.realtime.protection.server.defense.template; import com.realtime.protection.configuration.entity.defense.template.Template; +import com.realtime.protection.configuration.utils.Counter; import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,9 +17,11 @@ import java.util.Map; public class TemplateService { private final TemplateMapper templateMapper; + private final Counter counter; - public TemplateService(TemplateMapper templateMapper) { + public TemplateService(TemplateMapper templateMapper, Counter counter) { this.templateMapper = templateMapper; + this.counter = counter; } @Transactional @@ -25,6 +30,13 @@ public class TemplateService { templateMapper.newProtectLevel(template.getProtectLevelMedium()); templateMapper.newProtectLevel(template.getProtectLevelHigh()); + template.setTemplateDisplayId( + "CLMB-" + + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + + "-" + + String.format("%06d", counter.generateId("strategy_template")) + ); + templateMapper.newTemplate(template); if (template.getTemplateId() == null) { diff --git a/src/main/java/com/realtime/protection/server/rule/staticrule/StaticRuleService.java b/src/main/java/com/realtime/protection/server/rule/staticrule/StaticRuleService.java index 487f126..c230e0b 100644 --- a/src/main/java/com/realtime/protection/server/rule/staticrule/StaticRuleService.java +++ b/src/main/java/com/realtime/protection/server/rule/staticrule/StaticRuleService.java @@ -196,7 +196,7 @@ public class StaticRuleService { List StaticRuleBatch = ListUtils.newArrayListWithExpectedSize(100); for (StaticRuleObject staticRule : list) { - staticRule.setStaticRuleCreateTime(LocalDateTime.now()); +// staticRule.setStaticRuleCreateTime(LocalDateTime.now()); staticRule.setStaticRuleDisplayId( "JTGZ-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) diff --git a/src/main/java/com/realtime/protection/server/whitelist/WhiteListService.java b/src/main/java/com/realtime/protection/server/whitelist/WhiteListService.java index 2d5ab37..e56e7cb 100644 --- a/src/main/java/com/realtime/protection/server/whitelist/WhiteListService.java +++ b/src/main/java/com/realtime/protection/server/whitelist/WhiteListService.java @@ -4,6 +4,7 @@ import com.alibaba.excel.util.ListUtils; import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject; import com.realtime.protection.configuration.entity.task.TaskCommandInfo; import com.realtime.protection.configuration.entity.whitelist.WhiteListObject; +import com.realtime.protection.configuration.utils.Counter; import com.realtime.protection.configuration.utils.SqlSessionWrapper; import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum; import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator; @@ -11,6 +12,8 @@ import com.realtime.protection.server.rule.staticrule.StaticRuleMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,18 +26,28 @@ public class WhiteListService { private final StaticRuleMapper staticRuleMapper; private final SqlSessionWrapper sqlSessionWrapper; + private final Counter counter; public WhiteListService(WhiteListMapper whiteListMapper, StaticRuleMapper staticRuleMapper, - SqlSessionWrapper sqlSessionWrapper) { + SqlSessionWrapper sqlSessionWrapper, Counter counter) { this.whiteListMapper = whiteListMapper; this.staticRuleMapper = staticRuleMapper; this.sqlSessionWrapper = sqlSessionWrapper; + this.counter = counter; } //新建一个whitelist public Integer newWhiteListObject(WhiteListObject object) { + object.setWhiteListDisplayId( + "BMD-" + + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + + "-" + + String.format("%06d", counter.generateId("white_list")) + + ); + whiteListMapper.newWhiteListObject(object); return object.getWhiteListId(); @@ -50,6 +63,13 @@ public class WhiteListService { List WhiteListBatch = ListUtils.newArrayListWithExpectedSize(100); for (WhiteListObject whiteListObject : whiteListObjectList) { + whiteListObject.setWhiteListDisplayId( + "BMD-" + + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + + "-" + + String.format("%06d", counter.generateId("white_list")) + + ); WhiteListBatch.add(whiteListObject); if (WhiteListBatch.size() < 100) { continue; diff --git a/src/main/resources/mappers/DynamicRuleMapper.xml b/src/main/resources/mappers/DynamicRuleMapper.xml index e6648d1..274f8ce 100644 --- a/src/main/resources/mappers/DynamicRuleMapper.xml +++ b/src/main/resources/mappers/DynamicRuleMapper.xml @@ -152,6 +152,8 @@ + + @@ -50,6 +52,7 @@ protect_object_id, protect_object_name, protect_object_system_name, INET_NTOA(protect_object_ip) as protect_object_ip, protect_object_port, protect_object_url, protect_object_protocol, protect_object_audit_status + ,protect_object_display_id FROM t_protect_object AND protect_object_name LIKE CONCAT('%', #{proobj_name}, '%') @@ -93,7 +96,7 @@ protect_object_port, protect_object_url, protect_object_protocol, - protect_object_audit_status + protect_object_audit_status,protect_object_display_id FROM t_protect_object WHERE protect_object_id = #{proobj_id} diff --git a/src/main/resources/mappers/StaticRuleMapper.xml b/src/main/resources/mappers/StaticRuleMapper.xml index 17aa31d..51b0dc8 100644 --- a/src/main/resources/mappers/StaticRuleMapper.xml +++ b/src/main/resources/mappers/StaticRuleMapper.xml @@ -135,6 +135,8 @@ + + diff --git a/src/main/resources/mappers/TemplateMapper.xml b/src/main/resources/mappers/TemplateMapper.xml index a3e5232..935791b 100644 --- a/src/main/resources/mappers/TemplateMapper.xml +++ b/src/main/resources/mappers/TemplateMapper.xml @@ -9,12 +9,12 @@ strategy_template_high_level_id, strategy_template_create_user_id, strategy_template_create_username, strategy_template_create_depart, - strategy_template_description) + strategy_template_description, strategy_template_display_id) VALUE (#{template.templateName}, #{template.sourceSystem}, #{template.protectLevelLow.protectLevelId}, #{template.protectLevelMedium.protectLevelId}, #{template.protectLevelHigh.protectLevelId}, #{template.createUserId}, #{template.createUsername}, #{template.createDepart}, - #{template.description}) + #{template.description}, #{template.templateDisplayId}) @@ -38,6 +38,8 @@ + + diff --git a/src/main/resources/mappers/WhiteListMapper.xml b/src/main/resources/mappers/WhiteListMapper.xml index c0a41f1..c1b967f 100644 --- a/src/main/resources/mappers/WhiteListMapper.xml +++ b/src/main/resources/mappers/WhiteListMapper.xml @@ -8,24 +8,24 @@ insert into t_white_list(white_list_name, white_list_system_name, white_list_ip, white_list_port, white_list_url, white_list_protocol, - white_list_audit_status, create_time) + white_list_audit_status, create_time, white_list_display_id) values (#{object.whiteListName}, #{object.whiteListSystemName}, INET_ATON(#{object.whiteListIP}), #{object.whiteListPort}, #{object.whiteListUrl}, #{object.whiteListProtocol}, - 0, NOW()) + 0, NOW(), #{object.whiteListDisplayId}) insert into t_white_list(white_list_name, white_list_system_name, white_list_ip, white_list_port, white_list_url, white_list_protocol, - white_list_audit_status, create_time) + white_list_audit_status, create_time, white_list_display_id) values (#{object.whiteListName}, #{object.whiteListSystemName}, INET_ATON(#{object.whiteListIP}), #{object.whiteListPort}, #{object.whiteListUrl}, #{object.whiteListProtocol}, - 0, NOW()) + 0, NOW(), #{object.whiteListDisplayId}) @@ -47,6 +47,8 @@ + +