Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmPwdStrategyQueryServiceImpl.java
@@ -1,17 +1,29 @@
package com.vci.frameworkcore.compatibility.impl;
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.omd.utils.ObjectTool;
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.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.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +55,12 @@
    private SmUserQueryServiceI smUserQueryService;
    /**
     * 平台调用客户端
     */
    @Autowired
    private PlatformClientUtil platformClientUtil;
    /**
     * 获取默认密码策略
     * @return
     */
@@ -62,6 +80,111 @@
    }
    /**
     * 密码策略分页查询
     * @param conditionMap
     * @param pageHelper
     * @return
     */
    @Override
    public DataGrid<SmPasswordStrategyVO> refDataGrid(Map<String, String> conditionMap, PageHelper pageHelper) throws PLException {
        if(pageHelper == null){
            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();
        List<SmPasswordStrategyForPlatform1> smPasswordStrategyForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmPasswordStrategyForPlatform1.class);
        DataGrid<SmPasswordStrategyVO> dataGrid = new DataGrid<>();
        if(!CollectionUtils.isEmpty(smPasswordStrategyForPlatform1s)){
            dataGrid.setData(pltPwdStrategy2SmPwdStrategyVOs(smPasswordStrategyForPlatform1s));
            dataGrid.setTotal(boService.countByQueryWrapper(queryWrapper,SmPasswordStrategyForPlatform1.class));
        }
        return dataGrid;
    }
    /**
     * 查询密码安全策略,下拉使用的接口
     * @param conditionMap
     * @return key为密码策略name,value为密码策略的oid
     * @throws VciBaseException
     */
    @Override
    public List<Map<String,String>> selectPwdStrategyMap(Map<String, String> conditionMap) throws PLException {
        PageHelper pageHelper = new PageHelper(-1);
        pageHelper.addDefaultAsc("plname");
        PasswordStrategyInfo[] passwordStrategyInfos = platformClientUtil.getFrameworkService().fetchAllPasswordStrategy();
        List<Map<String,String>> mapArrayList = new ArrayList<>();
        if(Func.isEmpty(passwordStrategyInfos)){
            return mapArrayList;
        }
        Arrays.stream(passwordStrategyInfos).forEach(item->{
            Map<String, String> map = new HashMap<>();
            map.put("name",item.name);
            map.put("id",item.id);
            mapArrayList.add(map);
        });
        return mapArrayList;
    }
    /**
     * 原平台密码策略转SmPasswordStrategyVOS对象
     * @param smPasswordStrategyForPlatform1s 原平台的密码策略
     * @return
     */
    private List<SmPasswordStrategyVO> pltPwdStrategy2SmPwdStrategyVOs(List<SmPasswordStrategyForPlatform1> smPasswordStrategyForPlatform1s){
        List<SmPasswordStrategyVO> smPasswordStrategyVOList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(smPasswordStrategyForPlatform1s)){
            smPasswordStrategyForPlatform1s.stream().forEach(s -> {
                smPasswordStrategyVOList.add(pltPwdStrategy2SmPwdStrategyVO(s));
            });
        }
        return smPasswordStrategyVOList;
    }
    /**
     * 原平台密码策略转SmPasswordStrategyVO对象
     * @param strategyForPlatform1 原平台的密码策略
     * @return 新的密码策略对象
     */
    private SmPasswordStrategyVO pltPwdStrategy2SmPwdStrategyVO(SmPasswordStrategyForPlatform1 strategyForPlatform1){
        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.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.setCreator(strategyForPlatform1.getPlcreateuser());
        strategyVO.setLastModifyTime(strategyForPlatform1.getPlupdatetime());
        strategyVO.setLastModifier(strategyForPlatform1.getPlupdateuser());
        strategyVO.getRequireCharType(strategyForPlatform1.getPcharspecies());
        strategyVO.setLicensors(strategyForPlatform1.getPllicensors());
        strategyVO.setRequireCharCount(strategyForPlatform1.getPlrequiredtype());
        return strategyVO;
    }
    /**
     * 保存用户关联密码策略
     * @param userIds
     * @param passwordStrategId
     * @return
     */
    @Override
    public boolean saveUserPasswordStrateg(String[] userIds, String passwordStrategId) throws PLException {
        VciBaseUtil.alertNotNull(userIds,"用户主键",passwordStrategId,"密码安全策略主键");
        //TODO:这里没有做查重处理,明天记得验证一下这儿是不是会自动做saveOrUpdate的处理
        return platformClientUtil.getFrameworkService().saveUserPasswordStrateg(userIds,passwordStrategId,new UserEntityInfo());
    }
    /**
     * 根据主键查询密码策略map对象
     * @param oidList
     * @return key为密码策略主键 value为密码策略