From ec2c06dabe9edaee7d28988d69a7bfd56eca3abd Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 20 九月 2024 15:39:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java | 285 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 264 insertions(+), 21 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java
index 36e1db7..daf15f0 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java
@@ -1,20 +1,18 @@
package com.vci.frameworkcore.compatibility.impl;
+import com.vci.dto.SmPasswordStrategyDTO;
import com.vci.corba.common.PLException;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.corba.framework.data.PasswordStrategyInfo;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.frameworkcore.compatibility.SmPwdStrategyQueryServiceI;
import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
-import com.vci.frameworkcore.constant.FrameWorkBtmTypeConstant;
-import com.vci.frameworkcore.enumpck.RoleClassifyEnum;
-import com.vci.frameworkcore.enumpck.RoleControlAreaEnum;
-import com.vci.frameworkcore.model.SmPasswordStrategyDO;
-import com.vci.frameworkcore.model.SmPasswordStrategyForPlatform1;
-import com.vci.frameworkcore.model.SmRoleForPlatform1;
-import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO;
-import com.vci.frameworkcore.pagemodel.SmRoleVO;
+import com.vci.frameworkcore.enumpck.CombinationEnum;
+import com.vci.model.SmPasswordStrategyDO;
+import com.vci.model.SmPasswordStrategyForPlatform1;
+import com.vci.pagemodel.SmPasswordStrategyVO;
import com.vci.omd.utils.ObjectTool;
+import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.pagemodel.PageHelper;
@@ -27,13 +25,16 @@
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
-import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
+
+import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
/**
* 瀵嗙爜绛栫暐鏌ヨ鏈嶅姟
@@ -60,6 +61,11 @@
*/
@Autowired
private PlatformClientUtil platformClientUtil;
+
+ /**
+ * 鏃ュ織
+ */
+ private Logger logger = LoggerFactory.getLogger(getClass());
/**
* 鑾峰彇榛樿瀵嗙爜绛栫暐
@@ -92,10 +98,8 @@
pageHelper = new PageHelper(-1);
}
pageHelper.addDefaultAsc("pname");
- VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmPasswordStrategyDO.class,pageHelper);
- //queryWrapper.eq("pltype","2");
- platformClientUtil.getFrameworkService().fetchAllPasswordStrategy();
- //platformClientUtil.getFrameworkService().fetchpassword();
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmPasswordStrategyForPlatform1.class,pageHelper);
+ //platformClientUtil.getFrameworkService().fetchAllPasswordStrategy();
List<SmPasswordStrategyForPlatform1> smPasswordStrategyForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmPasswordStrategyForPlatform1.class);
DataGrid<SmPasswordStrategyVO> dataGrid = new DataGrid<>();
if(!CollectionUtils.isEmpty(smPasswordStrategyForPlatform1s)){
@@ -134,11 +138,18 @@
* @param smPasswordStrategyForPlatform1s 鍘熷钩鍙扮殑瀵嗙爜绛栫暐
* @return
*/
- private List<SmPasswordStrategyVO> pltPwdStrategy2SmPwdStrategyVOs(List<SmPasswordStrategyForPlatform1> smPasswordStrategyForPlatform1s){
+ private List<SmPasswordStrategyVO> pltPwdStrategy2SmPwdStrategyVOs(List<SmPasswordStrategyForPlatform1> smPasswordStrategyForPlatform1s) throws PLException{
List<SmPasswordStrategyVO> smPasswordStrategyVOList = new ArrayList<>();
if(!CollectionUtils.isEmpty(smPasswordStrategyForPlatform1s)){
smPasswordStrategyForPlatform1s.stream().forEach(s -> {
- smPasswordStrategyVOList.add(pltPwdStrategy2SmPwdStrategyVO(s));
+ try {
+ smPasswordStrategyVOList.add(pltPwdStrategy2SmPwdStrategyVO(s));
+ } catch (PLException e) {
+ e.printStackTrace();
+ String exceptionMessage = "Platform1瀵硅薄杞琕O瀵硅薄鏃跺嚭鐜伴敊璇紝鍘熷洜锛�"+VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ throw new VciBaseException(exceptionMessage);
+ }
});
}
return smPasswordStrategyVOList;
@@ -149,27 +160,79 @@
* @param strategyForPlatform1 鍘熷钩鍙扮殑瀵嗙爜绛栫暐
* @return 鏂扮殑瀵嗙爜绛栫暐瀵硅薄
*/
- private SmPasswordStrategyVO pltPwdStrategy2SmPwdStrategyVO(SmPasswordStrategyForPlatform1 strategyForPlatform1){
+ private SmPasswordStrategyVO pltPwdStrategy2SmPwdStrategyVO(SmPasswordStrategyForPlatform1 strategyForPlatform1) throws PLException {
SmPasswordStrategyVO strategyVO = new SmPasswordStrategyVO();
strategyVO.setOid(strategyForPlatform1.getPluid());
strategyVO.setId("");
strategyVO.setName(strategyForPlatform1.getPname());
strategyVO.setMaxLength(strategyForPlatform1.getPlmaxlength());
strategyVO.setMinLength(strategyForPlatform1.getPlength());
- strategyVO.setValidDay(strategyForPlatform1.getPremindday());
+ strategyVO.setValidDay(strategyForPlatform1.getPoverdueday());
strategyVO.setRemindDay(strategyForPlatform1.getPremindday());
strategyVO.setRetryTime(strategyForPlatform1.getPretrytime());
strategyVO.setLockTime(strategyForPlatform1.getPlocktime());
strategyVO.setDefaultFlag(strategyForPlatform1.getPlisdefault() == 1);
strategyVO.setDescription(strategyForPlatform1.getPldesc());
- strategyVO.setCreateTime(strategyForPlatform1.getPlcreatetime());
+ strategyVO.setCreateTime(new Date(strategyForPlatform1.getPlcreatetime()));
strategyVO.setCreator(strategyForPlatform1.getPlcreateuser());
- strategyVO.setLastModifyTime(strategyForPlatform1.getPlupdatetime());
+ strategyVO.setLastModifyTime(new Date(strategyForPlatform1.getPlupdatetime()));
strategyVO.setLastModifier(strategyForPlatform1.getPlupdateuser());
- strategyVO.getRequireCharType(strategyForPlatform1.getPcharspecies());
strategyVO.setLicensors(strategyForPlatform1.getPllicensors());
strategyVO.setRequireCharCount(strategyForPlatform1.getPlrequiredtype());
+ //澶勭悊瀵嗙爜绛栫暐鐨勭粍鍚堟柟寮�
+ Integer plchartypes = strategyForPlatform1.getPlchartypes();
+ if(Func.isNotEmpty(plchartypes)){
+ String combinations = plchartypes2Combinations(plchartypes);
+ strategyVO.setRequireCharType(combinations);
+ strategyVO.setRequireCharTypeText(CombinationEnum.getCombinationText(combinations));
+ }
return strategyVO;
+ }
+
+ /**
+ * plchartypes杞崲涓篊ombinations锛堣嫳鏂囷級
+ * @param plchartypes
+ * @return 杩涘埗鏁拌浆鎹负缁勫悎鏂瑰紡鐨勫洜涓烘灇涓惧涓箣闂寸敤閮藉ソ闂撮殧
+ */
+ private String plchartypes2Combinations(Integer plchartypes){
+ StringBuilder sb = new StringBuilder();
+ if ((plchartypes & 0x01) == 0x01)
+ sb.append("number,");
+ if ((plchartypes & 0x02) == 0x02)
+ sb.append("lower,");
+ if ((plchartypes & 0x04) == 0x04)
+ sb.append("upper,");
+ if ((plchartypes & 0x08) == 0x08)
+ sb.append("symbol,");
+ return sb.deleteCharAt(sb.length() - 1).toString();
+ }
+
+ /**
+ * plchartypes杞崲涓篊ombinations锛堣嫳鏂囷級
+ * @param combinations
+ * @return 缁勫悎鏂瑰紡杞崲涓哄疄闄呰瀛樺偍鐨勬暣褰㈡暟
+ */
+ private short combinations2Plchartypes(String combinations) {
+ short plchartypes = 0;
+ String[] combinationsArray = combinations.split(",");
+ for (String type : combinationsArray) {
+ switch (type) {
+ case "number":
+ plchartypes |= 0x01;
+ break;
+ case "lower":
+ plchartypes |= 0x02;
+ break;
+ case "upper":
+ plchartypes |= 0x04;
+ break;
+ case "symbol":
+ plchartypes |= 0x08;
+ break;
+ }
+ }
+
+ return plchartypes;
}
/**
@@ -181,7 +244,6 @@
@Override
public boolean saveUserPasswordStrateg(String[] userIds, String passwordStrategId) throws PLException {
VciBaseUtil.alertNotNull(userIds,"鐢ㄦ埛涓婚敭",passwordStrategId,"瀵嗙爜瀹夊叏绛栫暐涓婚敭");
- //TODO锛氳繖閲屾病鏈夊仛鏌ラ噸澶勭悊锛屾槑澶╄寰楅獙璇佷竴涓嬭繖鍎挎槸涓嶆槸浼氳嚜鍔ㄥ仛saveOrUpdate鐨勫鐞�
return platformClientUtil.getFrameworkService().saveUserPasswordStrateg(
userIds,
passwordStrategId,
@@ -190,6 +252,187 @@
}
/**
+ * 瀵嗙爜绛栫暐鏍¢獙锛氭槸鍚﹀悎瑙勬牎楠�
+ * @param strategy
+ */
+ private void checkPwdStrategy(SmPasswordStrategyDTO strategy){
+ if(strategy.getRequireCharCount() > strategy.getCombinations().split(",").length){
+ throw new VciBaseException("蹇呭~绉嶇被涓嶈兘澶т簬鎵�閫夋嫨鐨勫瘑鐮佺粍鍚堟柟寮忕殑涓暟!");
+ }
+ if(strategy.getMaxLength() < strategy.getMinLength()){
+ throw new VciBaseException("瀵嗙爜鏈�澶ч暱搴︿笉鑳藉皬浜庢渶灏忛暱搴�!");
+ }
+ if(Func.isNotEmpty(strategy.getRequireCharCount()) &&
+ (strategy.getMinLength() < strategy.getRequireCharCount() ||
+ strategy.getMaxLength() < strategy.getRequireCharCount())
+ ){
+ throw new VciBaseException("瀵嗙爜鏈�灏忛暱搴︿笉鑳藉皬浜庡繀濉绫荤殑鍊�!");
+ }
+ if(strategy.getValidDay() <= strategy.getRemindDay()){
+ throw new VciBaseException("杩囨湡鏃堕棿涓嶈兘灏忎簬鎻愰啋鏃堕棿!");
+ }
+ //鍒ゆ柇鍓嶇鏄惁鏈彁浜わ紝鏄惁榛樿瀛楁
+ if(Func.isEmpty(strategy.getDefaultFlag())){
+ strategy.setDefaultFlag("false");
+ }
+ }
+
+ /**
+ * dto瀵硅薄杞崲涓篿nfo瀵硅薄
+ * @param dto
+ * @return
+ */
+ private PasswordStrategyInfo changePasswordStrategyDTO2Info(SmPasswordStrategyDTO dto){
+ PasswordStrategyInfo info = new PasswordStrategyInfo();
+ info.id = dto.getOid() == null ? "" : dto.getOid();
+ info.name = dto.getName();
+ info.passwordLen = dto.getMinLength();
+ info.passwordMaxLen = dto.getMaxLength();
+ info.charTypes = dto.getRequireCharType();
+ info.requiredType = dto.getRequireCharCount();
+ //閫炬湡鏃�=鏈夋晥澶╂暟
+ info.overdueDay = dto.getValidDay();
+ info.remideDay = dto.getRemindDay();
+ info.retryTime = dto.getRetryTime();
+ info.lockTime = dto.getLockTime();
+ if(dto.getDefaultFlag().equals("1") || dto.getDefaultFlag().equals("true")){
+ info.isDefault = true;
+ }else {
+ info.isDefault = false;
+ }
+ info.desc = dto.getDescription() == null ? "" : dto.getDescription();
+ info.createTime = dto.getCreateTime() == null ? System.currentTimeMillis() : dto.getCreateTime().getTime();
+ info.createUser = dto.getCreator() == null ? "" : dto.getCreator();
+ info.updateTime = System.currentTimeMillis();
+ info.updateUser = dto.getLastModifier() == null ? "" : dto.getLastModifier();
+ return info;
+ }
+
+ /**
+ * 鏍规嵁map鏉′欢鏌ヨ瀵嗙爜绛栫暐
+ * @param conditionMap
+ * @return
+ */
+ private List<SmPasswordStrategyVO> getPwdStrategyByCondition(Map<String,String> conditionMap) throws PLException {
+ if(Func.isEmpty(conditionMap)){
+ conditionMap = new HashMap();
+ }
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmPasswordStrategyForPlatform1.class);
+ List<SmPasswordStrategyForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmPasswordStrategyForPlatform1.class);
+ if(Func.isEmpty(roleForPlatform1s)){
+ return null;
+ }
+ return pltPwdStrategy2SmPwdStrategyVOs(roleForPlatform1s);
+ }
+
+ /**
+ * 鏂板瀵嗙爜绛栫暐
+ * @param spsDto
+ * @return
+ */
+ @Override
+ public boolean addPasswordStrateg(SmPasswordStrategyDTO spsDto) throws PLException {
+ VciBaseUtil.alertNotNull(
+ spsDto,"鏂板鐨勫瘑鐮佺瓥鐣ュ璞�",
+ spsDto.getName(),"绛栫暐鍚嶇О",
+ spsDto.getMinLength(),"瀵嗙爜鏈�灏忛暱搴�",
+ spsDto.getMaxLength(),"瀵嗙爜鏈�澶ч暱搴�",
+ spsDto.getCombinations(),"缁勫悎鏂瑰紡绉嶇被",
+ spsDto.getRequireCharCount(),"蹇呭~绉嶇被",
+ spsDto.getValidDay(),"杩囨湡鏃堕棿",
+ spsDto.getRemindDay(),"鎻愰啋鏃堕棿",
+ spsDto.getRetryTime(),"閲嶈瘯娆℃暟",
+ spsDto.getLockTime(),"閿佸畾鏃堕棿"
+ );
+ //瀵嗙爜绛栫暐鍚堣鏍¢獙锛屼笉鍚堣浼氭姏鍑洪敊璇�
+ this.checkPwdStrategy(spsDto);
+ //鏍规嵁绛栫暐鍚嶇О鏌ラ噸
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("pname",spsDto.getName());
+ List<SmPasswordStrategyVO> dbVoList = this.getPwdStrategyByCondition(conditionMap);
+ if(Func.isNotEmpty(dbVoList)){
+ throw new VciBaseException("绛栫暐鍚嶇О宸茬粡瀛樺湪锛岃杩涜淇敼!");
+ }
+ //鑾峰彇褰撳墠鐢ㄦ埛璐﹀彿淇℃伅锛氬钩鍙颁繚瀛樻柟娉曚腑浼氬皢userEntityInfo涓殑鐢ㄦ埛淇℃伅鐢ㄤ綔褰撳墠绛栫暐鐨勫垱寤轰汉鍜屼慨鏀逛汉
+ String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+ UserEntityInfo userEntityInfo = new UserEntityInfo(userId,null);
+ //缁勫悎鏂瑰紡杞崲涓哄瓨鍌ㄥ��
+ spsDto.setRequireCharType(combinations2Plchartypes(spsDto.getCombinations()));
+ spsDto.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
+ spsDto.setCreator(userId);
+ spsDto.setLastModifier(userId);
+ //杞崲涓哄瓨鍌ㄧ敤瀵硅薄
+ PasswordStrategyInfo passwordStrategyInfo = changePasswordStrategyDTO2Info(spsDto);
+ //褰撹缃负榛樿绛栫暐鏃讹紝骞冲彴淇濆瓨鏂规硶浼氳嚜鍔ㄥ鐞嗘帀宸插瓨鍦ㄧ殑榛樿绛栫暐锛屼互淇濊瘉鍙湁涓�鏉¢粯璁ょ瓥鐣�
+ return platformClientUtil.getFrameworkService().savePasswordStrategy(passwordStrategyInfo, userEntityInfo);
+ }
+
+ /**
+ * 淇敼瀵嗙爜绛栫暐
+ * @param spsDto
+ * @return
+ */
+ @Override
+ public boolean updatePasswordStrateg(SmPasswordStrategyDTO spsDto) throws PLException {
+ VciBaseUtil.alertNotNull(
+ spsDto,"鏂板鐨勫瘑鐮佺瓥鐣ュ璞�",
+ spsDto.getOid(),"绛栫暐涓婚敭",
+ spsDto.getName(),"绛栫暐鍚嶇О",
+ spsDto.getMinLength(),"瀵嗙爜鏈�灏忛暱搴�",
+ spsDto.getMaxLength(),"瀵嗙爜鏈�澶ч暱搴�",
+ spsDto.getCombinations(),"缁勫悎鏂瑰紡绉嶇被",
+ spsDto.getRequireCharCount(),"蹇呭~绉嶇被",
+ spsDto.getValidDay(),"杩囨湡鏃堕棿",
+ spsDto.getRemindDay(),"鎻愰啋鏃堕棿",
+ spsDto.getRetryTime(),"閲嶈瘯娆℃暟",
+ spsDto.getLockTime(),"閿佸畾鏃堕棿"
+ );
+ //瀵嗙爜绛栫暐鍚堣鏍¢獙锛屼笉鍚堣浼氭姏鍑洪敊璇�
+ this.checkPwdStrategy(spsDto);
+ //鏌ヨ淇敼鐨勭瓥鐣ユ槸鍚﹀瓨鍦�
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("pluid",spsDto.getOid());
+ List<SmPasswordStrategyVO> dbVoList = this.getPwdStrategyByCondition(conditionMap);
+ if(Func.isEmpty(dbVoList)){
+ throw new VciBaseException("褰撳墠淇敼鐨勫瘑鐮佺瓥鐣ュ湪绯荤粺涓笉瀛樺湪锛岃鍒锋柊鍚庨噸璇�!");
+ }
+ //鑾峰彇褰撳墠鐢ㄦ埛璐﹀彿淇℃伅
+ String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+ UserEntityInfo userEntityInfo = new UserEntityInfo(userId,null);
+ //鏍规嵁绛栫暐鍚嶇О鏌ラ噸
+ conditionMap.clear();
+ conditionMap.put("pname",spsDto.getName());
+ conditionMap.put("pluid", QueryOptionConstant.NOTEQUAL + spsDto.getOid());
+ List<SmPasswordStrategyVO> repeatVoList = this.getPwdStrategyByCondition(conditionMap);
+ if(Func.isNotEmpty(repeatVoList)){
+ throw new VciBaseException("绛栫暐鍚嶇О宸茬粡瀛樺湪锛岃杩涜淇敼!");
+ }
+ SmPasswordStrategyVO smPasswordStrategyVO = dbVoList.get(0);
+ spsDto.setCreateTime(smPasswordStrategyVO.getCreateTime());
+ spsDto.setCreator(smPasswordStrategyVO.getCreator());
+ spsDto.setLastModifier(userId);
+ //缁勫悎鏂瑰紡杞崲涓哄瓨鍌ㄥ��
+ spsDto.setRequireCharType(combinations2Plchartypes(spsDto.getCombinations()));
+ PasswordStrategyInfo passwordStrategyInfo = changePasswordStrategyDTO2Info(spsDto);
+ return platformClientUtil.getFrameworkService().editPasswordStrategy(passwordStrategyInfo,userEntityInfo);
+ }
+
+ /**
+ * 鍒犻櫎瀵嗙爜绛栫暐
+ * @param pwdIds
+ * @return
+ */
+ @Override
+ public boolean delPasswordStrateg(String[] pwdIds) throws PLException {
+ VciBaseUtil.alertNotNull(pwdIds,"瑕佸垹闄ょ殑瀵嗙爜绛栫暐涓婚敭");
+ //TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝绛栫暐鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤绛栫暐淇℃伅杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
+ return platformClientUtil.getFrameworkService().deletePasswordStrategy(
+ pwdIds,
+ new UserEntityInfo("developer"/*WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()*/, null)
+ );
+ }
+
+ /**
* 鏍规嵁涓婚敭鏌ヨ瀵嗙爜绛栫暐map瀵硅薄
* @param oidList
* @return key涓哄瘑鐮佺瓥鐣ヤ富閿� value涓哄瘑鐮佺瓥鐣�
--
Gitblit v1.9.3