From dcd238531d8154633b9c1e2188b81e519760a17e Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期二, 16 七月 2024 16:09:45 +0800
Subject: [PATCH] 调整项目结构,统一DTO、VO、PO、BO等对象到plt-web-api模块下,拷贝vci-file-integration、plt-web-api、vci-framework-api、vci-file-api等依赖下的对象到plt-web-api模块下,并取消对这些jar的引用(为了解决同路径同名独享导致打包运行时对象加载出错问题)。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java |  292 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 270 insertions(+), 22 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 e9a2c13..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,38 +1,40 @@
 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;
 import com.vci.starter.web.util.BeanUtil;
 import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.starter.web.util.WebThreadLocalUtil;
 import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
 import com.vci.web.service.WebBoServiceI;
 import com.vci.web.util.Func;
 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;
 
 /**
  * 瀵嗙爜绛栫暐鏌ヨ鏈嶅姟
@@ -59,6 +61,11 @@
      */
     @Autowired
     private PlatformClientUtil platformClientUtil;
+
+    /**
+     * 鏃ュ織
+     */
+    private Logger logger = LoggerFactory.getLogger(getClass());
 
     /**
      * 鑾峰彇榛樿瀵嗙爜绛栫暐
@@ -91,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)){
@@ -133,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;
@@ -148,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;
     }
 
     /**
@@ -180,8 +244,192 @@
     @Override
     public boolean saveUserPasswordStrateg(String[] userIds, String passwordStrategId) throws PLException {
         VciBaseUtil.alertNotNull(userIds,"鐢ㄦ埛涓婚敭",passwordStrategId,"瀵嗙爜瀹夊叏绛栫暐涓婚敭");
-        //TODO锛氳繖閲屾病鏈夊仛鏌ラ噸澶勭悊锛屾槑澶╄寰楅獙璇佷竴涓嬭繖鍎挎槸涓嶆槸浼氳嚜鍔ㄥ仛saveOrUpdate鐨勫鐞�
-        return platformClientUtil.getFrameworkService().saveUserPasswordStrateg(userIds,passwordStrategId,new UserEntityInfo());
+        return platformClientUtil.getFrameworkService().saveUserPasswordStrateg(
+                userIds,
+                passwordStrategId,
+                new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(),null)
+        );
+    }
+
+    /**
+     * 瀵嗙爜绛栫暐鏍¢獙锛氭槸鍚﹀悎瑙勬牎楠�
+     * @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)
+        );
     }
 
     /**

--
Gitblit v1.9.3