summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangshuai <[email protected]>2023-11-02 10:51:42 +0800
committerzhangshuai <[email protected]>2023-11-02 10:51:42 +0800
commitb42c0906ff220d0335bf6ee4f9721c07c0570542 (patch)
tree0aa59376d7c3c2d1c4c5352b069971d379bbf640
parenta0f3335626d55d6e6d8383f0c240ff117d2bba56 (diff)
fix: NEZ-3306 alertRule 不允许创建相同的 oidrel-23.10.08
-rw-r--r--nz-admin/src/main/java/com/nis/modules/alert/service/impl/AlertRuleServiceImpl.java11
-rw-r--r--nz-common/src/main/java/com/nis/common/utils/RCode.java1
2 files changed, 12 insertions, 0 deletions
diff --git a/nz-admin/src/main/java/com/nis/modules/alert/service/impl/AlertRuleServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/alert/service/impl/AlertRuleServiceImpl.java
index 26da7cb5..86a1b01c 100644
--- a/nz-admin/src/main/java/com/nis/modules/alert/service/impl/AlertRuleServiceImpl.java
+++ b/nz-admin/src/main/java/com/nis/modules/alert/service/impl/AlertRuleServiceImpl.java
@@ -181,6 +181,17 @@ public class AlertRuleServiceImpl extends ServiceImpl<AlertRuleDao, AlertRuleEnt
// 校验参数
this.validateParam(alertRule);
+ // 校验 oid 是否重复
+ if (AlertRuleType.SNMP_TRAP.getValue().equals(alertRule.getType())) {
+ List<AlertRuleEntity> alertRuleEntitys = this.list(new LambdaQueryWrapper<AlertRuleEntity>()
+ .eq(AlertRuleEntity::getExpr, alertRule.getExpr())
+ .eq(AlertRuleEntity::getType, AlertRuleType.SNMP_TRAP.getValue())
+ .ne(ObjectUtil.isNotEmpty(alertRule.getId()), AlertRuleEntity::getId, alertRule.getId()));
+ if (CollectionUtils.isNotEmpty(alertRuleEntitys)) {
+ throw new NZException(RCode.ALERTRULE_EXPR_DUPLICATE);
+ }
+ }
+
// 校验名称重复
if (!this.checkName(alertRule)) {
throw new NZException(RCode.ALERTRULE_NAME_DUPLICATE);
diff --git a/nz-common/src/main/java/com/nis/common/utils/RCode.java b/nz-common/src/main/java/com/nis/common/utils/RCode.java
index c391372a..a1fcede5 100644
--- a/nz-common/src/main/java/com/nis/common/utils/RCode.java
+++ b/nz-common/src/main/java/com/nis/common/utils/RCode.java
@@ -508,6 +508,7 @@ public enum RCode {
ALERTRULE_SNMPTRAP_OPERATOR_ERROR(423049, "The SNMP trap type operator only supports regex"),
ALERTRULE_SELECT_DASHBOARD_TYPE_INCORRECT(424050,"Incorrect type selection, only `dashboard` type dashboard is supported"),
ALERTRULE_PARAM_FORMAT_ERROR(423051, "Parameter format error"),
+ ALERTRULE_EXPR_DUPLICATE(423052, "Alert rule oid already exists"),