|
@ -1,6 +1,5 @@ |
|
|
package com.win.module.wms.service.rule; |
|
|
package com.win.module.wms.service.rule; |
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import cn.hutool.json.JSONArray; |
|
|
import cn.hutool.json.JSONArray; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import cn.hutool.json.JSONUtil; |
|
@ -39,7 +38,7 @@ public class RuleServiceImpl implements RuleService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Long createRule(RuleCreateReqVO createReqVO) { |
|
|
public Long createRule(RuleCreateReqVO createReqVO) { |
|
|
validateRuleForCreateOrUpdate(createReqVO.getId(),createReqVO.getCode(),createReqVO.getStrategyCode(),createReqVO.getPriority()); |
|
|
validateRuleForCreateOrUpdate(createReqVO.getId(),createReqVO.getStrategyCode(),createReqVO.getPriority()); |
|
|
// 插入
|
|
|
// 插入
|
|
|
RuleDO rule = RuleConvert.INSTANCE.convert(createReqVO); |
|
|
RuleDO rule = RuleConvert.INSTANCE.convert(createReqVO); |
|
|
ruleMapper.insert(rule); |
|
|
ruleMapper.insert(rule); |
|
@ -50,7 +49,7 @@ public class RuleServiceImpl implements RuleService { |
|
|
@Override |
|
|
@Override |
|
|
public void updateRule(RuleUpdateReqVO updateReqVO) { |
|
|
public void updateRule(RuleUpdateReqVO updateReqVO) { |
|
|
// 校验存在
|
|
|
// 校验存在
|
|
|
validateRuleForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getCode(),updateReqVO.getStrategyCode(),updateReqVO.getPriority()); |
|
|
validateRuleForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getStrategyCode(),updateReqVO.getPriority()); |
|
|
// 更新
|
|
|
// 更新
|
|
|
RuleDO updateObj = RuleConvert.INSTANCE.convert(updateReqVO); |
|
|
RuleDO updateObj = RuleConvert.INSTANCE.convert(updateReqVO); |
|
|
ruleMapper.updateById(updateObj); |
|
|
ruleMapper.updateById(updateObj); |
|
@ -79,12 +78,11 @@ public class RuleServiceImpl implements RuleService { |
|
|
return ruleMapper.selectPage(pageReqVO); |
|
|
return ruleMapper.selectPage(pageReqVO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void validateRuleForCreateOrUpdate(Long id, String code, String strategyCode,Integer priority) { |
|
|
private void validateRuleForCreateOrUpdate(Long id, String strategyCode,Integer priority) { |
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
DataPermissionUtils.executeIgnore(() -> { |
|
|
DataPermissionUtils.executeIgnore(() -> { |
|
|
validateRuleExists(id); |
|
|
validateRuleExists(id); |
|
|
// 校验code唯一
|
|
|
// 校验code唯一
|
|
|
validateCode(code); |
|
|
|
|
|
validateStrategyCode(strategyCode); |
|
|
validateStrategyCode(strategyCode); |
|
|
validatePriority(priority); |
|
|
validatePriority(priority); |
|
|
}); |
|
|
}); |
|
@ -99,15 +97,6 @@ public class RuleServiceImpl implements RuleService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
|
|
private void validateCode(String code) { |
|
|
|
|
|
if (code.isEmpty()) { |
|
|
|
|
|
throw exception(RULE_CODE_NOT_EXISTS); |
|
|
|
|
|
} |
|
|
|
|
|
if (StrUtil.isBlank(code)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
@VisibleForTesting |
|
|
@VisibleForTesting |
|
|
private void validateStrategyCode(String strategyCode) { |
|
|
private void validateStrategyCode(String strategyCode) { |
|
|
if (strategyCode.isEmpty()) { |
|
|
if (strategyCode.isEmpty()) { |
|
|