| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public boolean addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { |
| | | public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "需要添加的数据对象"); |
| | | if(checkCodeRuleRepeat(codeRuleDTO.getId())){ |
| | | return R.fail("规则编号已存在!"); |
| | | } |
| | | // 将DTO转换为DO |
| | | CodeRule codeRule = Objects.requireNonNull(BeanUtil.copy(codeRuleDTO, CodeRule.class)); |
| | | // 填充默认值 |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE); |
| | | codeRule.setLctid(CODE_RULE_LC); |
| | | codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING); |
| | | return codeRuleMapper.insert(codeRule)>0; |
| | | return R.status(codeRuleMapper.insert(codeRule)>0); |
| | | } |
| | | |
| | | /** |
| | | * 检查id编号是否重复 |
| | | * @param id 当前编号 |
| | | * @return 返回false表示未重复 |
| | | */ |
| | | @Override |
| | | public boolean checkCodeRuleRepeat(String id){ |
| | | Long count = this.codeRuleMapper.selectCount(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, id)); |
| | | if(count>0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public boolean editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{ |
| | | public R editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "数据对象", codeRuleDTO.getOid(), "主数据编码规则主键"); |
| | | if(checkCodeRuleRepeat(codeRuleDTO.getId())){ |
| | | return R.fail("规则编号已存在!"); |
| | | } |
| | | if (!checkEditDelStatus(codeRuleDTO.getLcStatus())) { |
| | | throw new VciBaseException("编码规则已发布,不允许编辑或删除"); |
| | | } |
| | |
| | | CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); |
| | | return codeRuleMapper.updateById(codeRule)>0; |
| | | return R.status(codeRuleMapper.updateById(codeRule)>0); |
| | | } |
| | | |
| | | /** |