1、策略模板、白名单增加display_id

2、所有对象的查询新增display_id字段

(cherry picked from commit b6061f58e1)
This commit is contained in:
PushM
2024-05-08 10:41:47 +08:00
parent 7f078a81fd
commit 1b7460be64
11 changed files with 65 additions and 10 deletions

View File

@@ -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;
/**
* 设置是否含有日常/应急/紧急防护等级态字段的字段

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -196,7 +196,7 @@ public class StaticRuleService {
List<StaticRuleObject> 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"))

View File

@@ -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<WhiteListObject> 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;