|
@@ -1,6 +1,7 @@
|
|
|
package com.sundata.internalevaluation.configuration.service;
|
|
|
|
|
|
import com.sundata.common.exception.BusinessException;
|
|
|
+import com.sundata.common.util.StringUtil;
|
|
|
import com.sundata.internalevaluation.configuration.mapper.SysReqRuleMapper;
|
|
|
import com.sundata.internalevaluation.configuration.mapper.SysReqRulesMapper;
|
|
|
import com.sundata.internalevaluation.configuration.model.SysReqRule;
|
|
@@ -13,7 +14,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class SysReqRuleService {
|
|
@@ -58,15 +58,28 @@ public class SysReqRuleService {
|
|
|
* @return 返回影响行数
|
|
|
*/
|
|
|
public int insertIgnoreNull(SysReqRule sysReqRule) {
|
|
|
+ String ruleNo = sysReqRule.getRuleNo();
|
|
|
+ if (StringUtil.isEmpty(ruleNo)) {
|
|
|
+ throw new BusinessException("规则编码不能为空.");
|
|
|
+ }
|
|
|
try {
|
|
|
- sysReqRuleMapper.deleteIndexByRuleNo(sysReqRule.getRuleNo());
|
|
|
- List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
|
|
|
- sysReqRuleMapper.insertIndexList(list);
|
|
|
+ sysReqRuleMapper.deleteIndexByRuleNo(ruleNo);
|
|
|
+ List<SysRuleIndex> ruleIndexList = sysReqRule.getRuleIndexList();
|
|
|
+ ruleIndexList.forEach(ruleIndex -> ruleIndex.setRuleNo(ruleNo));
|
|
|
+// List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
|
|
|
+ insertIndexList(ruleIndexList);
|
|
|
return sysReqRuleMapper.insertIgnoreNull(sysReqRule);
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
throw new BusinessException("规则编码已存在,请重新输入.");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public int insertIndexList(List<SysRuleIndex> list){
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return sysReqRuleMapper.insertIndexList(list);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -79,9 +92,13 @@ public class SysReqRuleService {
|
|
|
@Transactional
|
|
|
public int updateIgnoreNull(SysReqRule sysReqRule) {
|
|
|
|
|
|
- sysReqRuleMapper.deleteIndexByRuleNo(sysReqRule.getRuleNo());
|
|
|
- List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
|
|
|
- sysReqRuleMapper.insertIndexList(list);
|
|
|
+ String ruleNo = sysReqRule.getRuleNo();
|
|
|
+ sysReqRuleMapper.deleteIndexByRuleNo(ruleNo);
|
|
|
+
|
|
|
+ List<SysRuleIndex> ruleIndexList = sysReqRule.getRuleIndexList();
|
|
|
+ ruleIndexList.forEach(ruleIndex -> ruleIndex.setRuleNo(ruleNo));
|
|
|
+// List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
|
|
|
+ insertIndexList(ruleIndexList);
|
|
|
return sysReqRuleMapper.updateIgnoreNull(sysReqRule);
|
|
|
|
|
|
}
|