|
|
@ -84,7 +84,7 @@ public class RuleServiceImpl implements RuleService { |
|
|
|
DataPermissionUtils.executeIgnore(() -> { |
|
|
|
validateRuleExists(id); |
|
|
|
// 校验code唯一
|
|
|
|
validateCodeExists(id,code); |
|
|
|
validateCode(code); |
|
|
|
validateStrategyCode(strategyCode); |
|
|
|
validatePriority(priority); |
|
|
|
}); |
|
|
@ -100,24 +100,13 @@ public class RuleServiceImpl implements RuleService { |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateCodeExists(Long id,String code) { |
|
|
|
private void validateCode(String code) { |
|
|
|
if (code.isEmpty()) { |
|
|
|
throw exception(RULE_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
if (StrUtil.isBlank(code)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
RuleDO rule = ruleMapper.selectByCode(code); |
|
|
|
if (rule == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
// 如果 id 为空,说明不用比较是否为相同 id 的用户
|
|
|
|
if (id == null) { |
|
|
|
throw exception(RULE_CODE_EXISTS); |
|
|
|
} |
|
|
|
if (!rule.getId().equals(id)) { |
|
|
|
throw exception(RULE_CODE_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
@VisibleForTesting |
|
|
|
private void validateStrategyCode(String strategyCode) { |
|
|
|