From 79120a1740872fbb20a79d0cde0a3fa9f55ec285 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 31 七月 2024 17:29:12 +0800 Subject: [PATCH] 版本规则新增、修改接口上传。 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java | 108 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 90 insertions(+), 18 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java index 7a59184..08b20db 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java @@ -5,8 +5,10 @@ import com.vci.corba.omd.vrm.VersionRule; import com.vci.dto.OsRevisionRuleDTO; import com.vci.starter.web.annotation.log.VciUnLog; +import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; import com.vci.pagemodel.OsRevisionRuleVO; +import com.vci.starter.web.util.WebThreadLocalUtil; import com.vci.web.service.OsRevisionRuleServiceI; import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; @@ -17,7 +19,9 @@ import org.springframework.stereotype.Service; import javax.swing.*; +import java.awt.*; import java.util.*; +import java.util.List; import java.util.stream.Collectors; /** @@ -73,20 +77,85 @@ */ @Override public boolean addVersionRule(OsRevisionRuleDTO osRevisionRuleDTO) throws PLException { + //鍒ょ┖ + VciBaseUtil.alertNotNull(osRevisionRuleDTO,"鐗堟湰瑙勫垯瀵硅薄",osRevisionRuleDTO.getId(),"鐗堟湰瑙勫垯鍚嶇О"); + //鐗堟湰瑙勫垯鍚堣妫�楠� + this.checkVersionRule(osRevisionRuleDTO); + //鏌ラ噸 VersionRule vr = platformClientUtil.getVersionService().getVersionRule(osRevisionRuleDTO.getName()); //name涓嶄负绌� if(Func.isNotEmpty(vr) && !"".equals(vr.name)){ throw new PLException("500",new String[]{"鍚嶇О閲嶅璇锋洿鎹㈠悕绉�!"}); } - - platformClientUtil.getVersionService().addVersionRule(this.dto2VersionRule(osRevisionRuleDTO)); - return false; + return platformClientUtil.getVersionService().addVersionRule(this.dto2VersionRule(osRevisionRuleDTO)); } + /** + * 淇敼鐗堟湰瑙勫垯 + * @param osRevisionRuleDTO + * @return + */ @Override - public boolean updateVersionRule(OsRevisionRuleDTO osRevisionRuleDTO) { + public boolean updateVersionRule(OsRevisionRuleDTO osRevisionRuleDTO) throws PLException { + //鍒ょ┖ + VciBaseUtil.alertNotNull(osRevisionRuleDTO,"鐗堟湰瑙勫垯瀵硅薄",osRevisionRuleDTO.getId(),"鐗堟湰瑙勫垯鍚嶇О"); + //鍒ゆ柇鏄惁鍦ㄧ郴缁熶腑瀛樺湪 + VersionRule vr = platformClientUtil.getVersionService().getVersionRule(osRevisionRuleDTO.getName()); + //鐗堟湰瑙勫垯鍚堣妫�楠� + this.checkVersionRule(osRevisionRuleDTO); + //name涓嶄负绌� + if(Func.isEmpty(vr) && !"".equals(vr.name)){ + throw new PLException("500",new String[]{"淇敼鐨勭増鏈鍒欏湪绯荤粺涓笉瀛樺湪!"}); + } + return platformClientUtil.getVersionService().modifyVersionRule(this.dto2VersionRule(osRevisionRuleDTO)); + } - return false; + /** + * 妫�鏌ョ増鏈鍒欒缃殑鏄惁鍚堢悊 + * @param dto + */ + private void checkVersionRule(OsRevisionRuleDTO dto) throws PLException { + //鐗堟湰瑙勫垯鍚嶇О鍙兘涓鸿嫳鏂囧瓧姣� + String regex = "[a-z A-Z]*"; + if (!dto.getId().matches(regex)) { + throw new PLException("500",new String[]{"鍚嶇О鍙兘涓鸿嫳鏂囷紒"}); + } + //璺宠穬瀛楃鍙兘涓烘暟瀛楁垨鑰呭瓧姣� + if(Func.isNotBlank(dto.getJumpCharacter()) && (!(dto.getJumpCharacter().matches(regex)))){ + throw new PLException("500",new String[]{"璺宠穬瀛楃鍙兘涓烘暟瀛楁垨鑰呭瓧姣嶏紒"}); + } + //鍒濆鍊间笉鑳戒负绌轰笖鍙兘涓烘暟瀛楁垨鑰呭瓧姣嶆垨鑻辨枃鐘舵�佷笅鐨勭鍙� + String regex1 = "[A-Za-z0-9!@#$%^&*()-_=+{}':|;,.?/]+$"; + if(Func.isBlank(dto.getInitialValue()) || !dto.getInitialValue().matches(regex1)){ + throw new PLException("500",new String[]{"鍒濆鍊间笉鑳戒负绌轰笖鍙兘涓烘暟瀛楁垨鑰呭瓧姣嶆垨鑻辨枃鐘舵�佷笅鐨勭鍙凤紒"}); + } + if(dto.getInitialValue().length() + dto.getInitialValue().length() > 32) { + throw new PLException("500",new String[]{"鍒濆鍊间笉鑳借秴杩�32涓瓧绗︼紒"}); + } + //姝ラ暱涓嶈兘涓虹┖涓斿繀椤讳负1-9鐨勬鏁存暟 + String regex2 = "[1-9]"; + if(Func.isBlank(dto.getStepLength()) || (!dto.getStepLength().matches(regex2))){ + throw new PLException("500",new String[]{"姝ラ暱涓嶈兘涓虹┖涓斿繀椤讳负1-9鐨勬鏁存暟"}); + } + //鍓嶇紑鐩稿叧鍒ゆ柇 + String regex3 = "^\\s+.*"; + if(Func.isNotBlank(dto.getPrefixion()) && (dto.getPrefixion().matches(regex3))){ + throw new PLException("500",new String[]{"鍓嶇紑涓嶈兘浠ョ┖鏍煎紑澶�"}); + } + if (dto.getPrefixion().length() + dto.getPrefixion().length() > 32) { + throw new PLException("500",new String[]{"鍓嶇紑涓嶈兘瓒呰繃32涓瓧绗�"}); + } + //鍚庣紑鐩稿叧鍒ゆ柇 + String regex4 = "^*.\\s+$"; + if(Func.isNotBlank(dto.getSuffix()) && (dto.getSuffix().matches(regex4))){ + throw new PLException("500",new String[]{"鍚庣紑涓嶈兘浠ョ┖鏍肩粨灏�"}); + } + if (dto.getSuffix().length() + dto.getSuffix().length() > 32) { + throw new PLException("500",new String[]{"鍚庣紑涓嶈兘瓒呰繃32涓瓧绗�"}); + } + if (dto.getId().length() > 255) { + throw new PLException("500",new String[]{"鍚嶇О涓嶈兘瓒呰繃255涓瓧绗�"}); + } } /** @@ -97,15 +166,18 @@ VersionRule newVR = new VersionRule(); newVR.name = osRevisionRuleDTO.getId(); newVR.tag = osRevisionRuleDTO.getName(); - newVR.jumpCharacter = osRevisionRuleDTO.getPrefixCode(); - /*newVR.initialValue = jtf3.getText(); - newVR.stepLength = jtf4.getText(); - newVR.prefixion = jtf5.getText(); - newVR.suffix = jtf6.getText(); - newVR.description = jta.getText();*/ - String userName = ClientSessionUtility.getCurUserName(); - newVR.creator = userName; + newVR.description = osRevisionRuleDTO.getDescription(); + newVR.jumpCharacter = osRevisionRuleDTO.getJumpCharacter(); + newVR.initialValue = osRevisionRuleDTO.getInitialValue(); + newVR.stepLength = osRevisionRuleDTO.getStepLength(); + newVR.prefixion = osRevisionRuleDTO.getPrefixion(); + newVR.suffix = osRevisionRuleDTO.getSuffix(); + String userName = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); + long timeMillis = System.currentTimeMillis(); + newVR.creator = Func.isBlank(osRevisionRuleDTO.getCreator()) ? userName:osRevisionRuleDTO.getCreator(); + newVR.createTime = Func.isEmpty(osRevisionRuleDTO.getCreateTime()) ? timeMillis:osRevisionRuleDTO.getCreateTime().getTime(); newVR.modifier = userName; + newVR.modifyTime = timeMillis; return newVR; } @@ -148,11 +220,11 @@ ruleVO.setDescription(versionRule.description); ruleVO.setId(versionRule.name); ruleVO.setName(versionRule.tag); - ruleVO.setSerialStep(WebUtil.getInt(versionRule.stepLength)); - ruleVO.setSkipCode(versionRule.jumpCharacter); - ruleVO.setPrefixCode(versionRule.prefixion); - ruleVO.setSuffixCode(versionRule.suffix); - ruleVO.setStartCode(versionRule.initialValue); + ruleVO.setStepLength(WebUtil.getInt(versionRule.stepLength)); + ruleVO.setJumpCharacter(versionRule.jumpCharacter); + ruleVO.setPrefixion(versionRule.prefixion); + ruleVO.setSuffix(versionRule.suffix); + ruleVO.setInitialValue(versionRule.initialValue); //associated鏆傛椂娌℃湁浣跨敤 } return ruleVO; -- Gitblit v1.9.3