From 728546f4621e893019dea545f14b6e617301b15b Mon Sep 17 00:00:00 2001 From: ludc Date: 星期二, 11 七月 2023 09:09:21 +0800 Subject: [PATCH] 代码提交 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java index 4d6d88b..86eb60d 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java @@ -60,6 +60,7 @@ 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; @@ -130,15 +131,32 @@ * @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("瑙勫垯缂栧彿宸插瓨鍦紒"); + } // 灏咲TO杞崲涓篋O 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); + } + + /** + * 妫�鏌d缂栧彿鏄惁閲嶅 + * @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; } /** @@ -163,8 +181,11 @@ * @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("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎"); } @@ -172,7 +193,7 @@ CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); - return codeRuleMapper.updateById(codeRule)>0; + return R.status(codeRuleMapper.updateById(codeRule)>0); } /** -- Gitblit v1.9.3