¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.frameworkcore.compatibility.SmPwdStrategyQueryServiceI; |
| | | import com.vci.frameworkcore.compatibility.SmUserQueryServiceI; |
| | | import com.vci.frameworkcore.model.OrgDeptForPlatform1; |
| | | import com.vci.frameworkcore.pagemodel.OrgDepartmentVO; |
| | | import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO; |
| | | import com.vci.frameworkcore.pagemodel.SmRoleVO; |
| | | import com.vci.frameworkcore.pagemodel.SmUserVO; |
| | | 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.util.BeanUtil; |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.model.SmPasswordStrategyDO; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | /** |
| | | * å¯ç çç¥æ¥è¯¢æå¡ |
| | | * @author ludc |
| | | * @date 2024/6/24 16:33 |
| | | */ |
| | | @Service |
| | | public class SmPwdStrategyQueryServiceImpl implements SmPwdStrategyQueryServiceI { |
| | | |
| | | /** |
| | | * ä¸å¡æ°æ®æå¡ |
| | | */ |
| | | @Autowired |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * ç¨æ·æ¥è¯¢æå¡ |
| | | */ |
| | | @Autowired |
| | | private SmUserQueryServiceI smUserQueryService; |
| | | |
| | | /** |
| | | * è·åé»è®¤å¯ç çç¥ |
| | | * @return |
| | | */ |
| | | public SmPasswordStrategyVO getPasswordStrategyVOByDefault(){ |
| | | //è·åé»è®¤ç |
| | | VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class); |
| | | queryWrapperForDO.eq("plisdefault","1"); |
| | | List<BusinessObject> cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " + |
| | | queryWrapperForDO.getTableNick() + queryWrapperForDO.getLinkTableSql() + |
| | | (StringUtils.isBlank(queryWrapperForDO.getWhereSql()) ? "" : (" where " + queryWrapperForDO.getWhereSql())), null); |
| | | if(!CollectionUtils.isEmpty(cboList)){ |
| | | SmPasswordStrategyDO passwordStrategyDO = new SmPasswordStrategyDO(); |
| | | WebUtil.copyValueToObjectFromCbos(cboList.get(0),passwordStrategyDO); |
| | | return pwdStrategyDO2VO(passwordStrategyDO); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸»é®æ¥è¯¢å¯ç çç¥map对象 |
| | | * @param oidList |
| | | * @return key为å¯ç çç¥ä¸»é® value为å¯ç çç¥ |
| | | */ |
| | | @Override |
| | | public Map<String, SmPasswordStrategyVO> mapPasswordStrategyVOMapByOid(Collection<String> oidList) { |
| | | VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class); |
| | | queryWrapperForDO.in("oid",oidList.stream().collect(Collectors.joining(","))); |
| | | List<BusinessObject> cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " + |
| | | queryWrapperForDO.getTableNick() + queryWrapperForDO.getLinkTableSql() + |
| | | (StringUtils.isBlank(queryWrapperForDO.getWhereSql()) ? "" : (" where " + queryWrapperForDO.getWhereSql())), null); |
| | | Map<String,SmPasswordStrategyVO> smPasswordStrategyVOMap = new HashMap<>(); |
| | | if(Func.isEmpty(cboList)){ |
| | | return new HashMap<>(); |
| | | } |
| | | cboList.stream().forEach(item->{ |
| | | SmPasswordStrategyDO passwordStrategyDO = new SmPasswordStrategyDO(); |
| | | WebUtil.copyValueToObjectFromCbos(item,passwordStrategyDO); |
| | | SmPasswordStrategyVO passwordStrategyVO = new SmPasswordStrategyVO(); |
| | | BeanUtil.convert(passwordStrategyDO,passwordStrategyVO); |
| | | smPasswordStrategyVOMap.put(passwordStrategyVO.getOid(),passwordStrategyVO); |
| | | }); |
| | | return smPasswordStrategyVOMap; |
| | | } |
| | | |
| | | /** |
| | | * 使ç¨ä¸»é®è·åå¯ç çç¥ |
| | | * @param oid ä¸»é® |
| | | * @return å¯ç çç¥æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | public SmPasswordStrategyVO getPasswordStrategyVOByOid(String oid){ |
| | | VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class); |
| | | queryWrapperForDO.eq("oid",oid.trim()); |
| | | List<BusinessObject> cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " + |
| | | queryWrapperForDO.getTableNick() + queryWrapperForDO.getLinkTableSql() + |
| | | (StringUtils.isBlank(queryWrapperForDO.getWhereSql()) ? "" : (" where " + queryWrapperForDO.getWhereSql())), null); |
| | | if(!CollectionUtils.isEmpty(cboList)){ |
| | | SmPasswordStrategyDO passwordStrategyDO = new SmPasswordStrategyDO(); |
| | | WebUtil.copyValueToObjectFromCbos(cboList.get(0),passwordStrategyDO); |
| | | SmPasswordStrategyVO passwordStrategyVO = new SmPasswordStrategyVO(); |
| | | BeanUtil.convert(passwordStrategyDO,passwordStrategyVO); |
| | | return passwordStrategyVO; |
| | | }else{ |
| | | //è·åé»è®¤ç |
| | | queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class); |
| | | queryWrapperForDO.eq("plisdefault","1"); |
| | | cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " + |
| | | queryWrapperForDO.getTableNick() + queryWrapperForDO.getLinkTableSql() + |
| | | (StringUtils.isBlank(queryWrapperForDO.getWhereSql()) ? "" : (" where " + queryWrapperForDO.getWhereSql())), null); |
| | | if(!CollectionUtils.isEmpty(cboList)){ |
| | | SmPasswordStrategyDO passwordStrategyDO = new SmPasswordStrategyDO(); |
| | | WebUtil.copyValueToObjectFromCbos(cboList.get(0),passwordStrategyDO); |
| | | return pwdStrategyDO2VO(passwordStrategyDO); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 夿¡å¯ç çç¥do对象转vo对象 |
| | | * @param smPasswordStrategyDOList |
| | | * @return |
| | | */ |
| | | private List<SmPasswordStrategyVO> pwdStrategyDO2VOS(List<SmPasswordStrategyDO> smPasswordStrategyDOList){ |
| | | List<SmPasswordStrategyVO> smPasswordStrategyVOList = new ArrayList<>(); |
| | | if(Func.isEmpty(smPasswordStrategyDOList)) { |
| | | return smPasswordStrategyVOList; |
| | | } |
| | | smPasswordStrategyDOList.stream().forEach(item->{ |
| | | smPasswordStrategyVOList.add(pwdStrategyDO2VO(item)); |
| | | }); |
| | | return smPasswordStrategyVOList; |
| | | } |
| | | |
| | | /** |
| | | * å¯ç çç¥do对象转vo对象 |
| | | * @param smPasswordStrategyDO |
| | | * @return |
| | | */ |
| | | private SmPasswordStrategyVO pwdStrategyDO2VO(SmPasswordStrategyDO smPasswordStrategyDO){ |
| | | SmPasswordStrategyVO passwordStrategyVO = new SmPasswordStrategyVO(); |
| | | BeanUtil.convert(smPasswordStrategyDO,passwordStrategyVO); |
| | | return passwordStrategyVO; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·ç主é®ï¼è·åç¨æ·çå¯ç å®å
¨çç¥ |
| | | * @param userOid ç¨æ·çä¸»é® |
| | | * @return å¯ç å®å
¨çç¥çæ¾ç¤ºå¯¹è±¡ï¼å¦æä¸åå¨åä¼è¿åNull |
| | | * @throws VciBaseException åæ°ä¸ºç©ºæè
æ°æ®åºæ¥è¯¢åºéçæ¶å伿åºå¼å¸¸ |
| | | */ |
| | | @Override |
| | | public SmPasswordStrategyVO getPasswordStrategyVOByUserOid(String userOid) throws PLException { |
| | | WebUtil.alertNotNull(userOid,"ç¨æ·ç主é®"); |
| | | if(smUserQueryService.checkUserExist(null,userOid)){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | String sql = "select plpasswordstrategyuid,pluseruid from pluserpasswordstrategy where pluseruid = '"+ userOid +"')"; |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | if(Func.isNotEmpty(cbos)){ |
| | | return getPasswordStrategyVOByOid(ObjectTool.getNewBOAttributeValue(cbos.get(0), "plpasswordstrategyuid")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å¤æ¡ç¨æ·ä¸»é®ï¼è·åç¨æ·çå¯ç å®å
¨çç¥ |
| | | * @param userOids |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public List<SmPasswordStrategyVO> listSmPasswordStrategyVOByUserOids(Collection<String> userOids) { |
| | | WebUtil.alertNotNull(userOids,"ç¨æ·ç主é®"); |
| | | //å
æ¥å
³è表 |
| | | List<String> userPwdStrategyList = new ArrayList<>(); |
| | | WebUtil.switchCollectionForOracleIn(userOids).stream().forEach(userOidSplit->{ |
| | | //æ¥å
³è表sql |
| | | String sql = "select plpasswordstrategyuid,pluseruid from pluserpasswordstrategy where pluseruid in (" + WebUtil.toInSql(userOidSplit.toArray(new String[0])) + ")"; |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | cbos.stream().forEach(cbo->{ |
| | | userPwdStrategyList.add(ObjectTool.getNewBOAttributeValue(cbo,"plpasswordstrategyuid")); |
| | | }); |
| | | }); |
| | | return listSmPasswordStrategyVOByOids(userPwdStrategyList); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·ä¸»é®æ¥è¯¢å¯ç çç¥å
³è表ä¸çå¯ç çç¥ä¸»é® |
| | | * @param userOids |
| | | * @return keyä¸ºç¨æ·oidï¼value为å¯ç çç¥oid |
| | | */ |
| | | private Map<String,String> mapUserPwdStrategy(Collection<String> userOids){ |
| | | Map<String,String> userPwdStrategyMap = new HashMap<>(); |
| | | WebUtil.switchCollectionForOracleIn(userOids).stream().forEach(userOidSplit->{ |
| | | //æ¥å
³è表sql |
| | | String sql = "select plpasswordstrategyuid,pluseruid from pluserpasswordstrategy where pluseruid in (" + WebUtil.toInSql(userOidSplit.toArray(new String[0])) + ")"; |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | cbos.stream().forEach(cbo->{ |
| | | String pluseruid = ObjectTool.getNewBOAttributeValue(cbo, "pluseruid"); |
| | | String plpasswordstrategyuid = ObjectTool.getNewBOAttributeValue(cbo, "plpasswordstrategyuid"); |
| | | userPwdStrategyMap.put(pluseruid,plpasswordstrategyuid); |
| | | }); |
| | | }); |
| | | return userPwdStrategyMap; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸»é®ï¼æ¹éè·åå¯ç å®å
¨çç¥ä¸»é® |
| | | * @param oids |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public List<SmPasswordStrategyVO> listSmPasswordStrategyVOByOids(Collection<String> oids) { |
| | | VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class); |
| | | queryWrapperForDO.in("oid",oids.stream().collect(Collectors.joining(","))); |
| | | List<BusinessObject> cboList = boService.queryBySql(queryWrapperForDO.getSelectFieldSql() + " from plpasswordstrategy " + |
| | | queryWrapperForDO.getTableNick() + queryWrapperForDO.getLinkTableSql() + |
| | | (StringUtils.isBlank(queryWrapperForDO.getWhereSql()) ? "" : (" where " + queryWrapperForDO.getWhereSql())), null); |
| | | List<SmPasswordStrategyVO> smPasswordStrategyVOList = new ArrayList<>(); |
| | | if(Func.isEmpty(cboList)){ |
| | | return smPasswordStrategyVOList; |
| | | } |
| | | cboList.stream().forEach(item->{ |
| | | SmPasswordStrategyDO passwordStrategyDO = new SmPasswordStrategyDO(); |
| | | WebUtil.copyValueToObjectFromCbos(item,passwordStrategyDO); |
| | | SmPasswordStrategyVO passwordStrategyVO = new SmPasswordStrategyVO(); |
| | | BeanUtil.convert(passwordStrategyDO,passwordStrategyVO); |
| | | smPasswordStrategyVOList.add(passwordStrategyVO); |
| | | }); |
| | | return smPasswordStrategyVOList; |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ ¹æ®ç¨æ·ç䏻鮿¥è·åå¯ç çç¥ |
| | | * @param userOidCollection ç¨æ·ä¸»é®éå |
| | | * @return å¯ç çç¥çæ¾ç¤ºå¯¹è±¡ï¼keyæ¯ç¨æ·ä¸»é®,valueæ¯è¿ä¸ªç¨æ·å
³èçå¯ç çç¥ |
| | | */ |
| | | @Override |
| | | public Map<String, SmPasswordStrategyVO> batchSmPwdStrategyByUserOids(Collection<String> userOidCollection) { |
| | | if(CollectionUtils.isEmpty(userOidCollection)){ |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String,SmPasswordStrategyVO> smPasswordStrategyVOMap = new HashMap<>(); |
| | | Map<String,String> userPasswordStrategyVOMap = new HashMap<>(); |
| | | |
| | | Map<String/*ç¨æ·id*/, SmPasswordStrategyVO/*å¯ç çç¥*/> returnMap = new HashMap<>(); |
| | | WebUtil.switchCollectionForOracleIn(userOidCollection).stream().forEach(userOids->{ |
| | | //æ¥è¯¢å¯ç çç¥å
³èä¿¡æ¯ï¼keyä¸ºç¨æ·oidï¼value为å¯ç çç¥oid |
| | | Map<String, String> userPwdStrategyMap = mapUserPwdStrategy(userOids); |
| | | userPasswordStrategyVOMap.putAll(userPwdStrategyMap); |
| | | //æ¥è¯¢å¯ç çç¥ï¼key为å¯ç çç¥ä¸»é®ï¼value为å¯ç çç¥ |
| | | smPasswordStrategyVOMap.putAll(mapPasswordStrategyVOMapByOid(userPwdStrategyMap.values())); |
| | | }); |
| | | //æ¥è¯¢é»è®¤çå¯ç çç¥ |
| | | SmPasswordStrategyVO passwordStrategyVOByDefault = getPasswordStrategyVOByDefault(); |
| | | //循ç¯ç¨æ·idï¼æ¥è¯¢æ¯å¦æç¬¦åæ¡ä»¶çoid |
| | | userOidCollection.stream().forEach(oid->{ |
| | | SmPasswordStrategyVO smPasswordStrategyVO; |
| | | //éè¿ç¨æ·oid没è·åå°å¯ç çç¥oidï¼è¯´ææ²¡æç»å½åç¨æ·è®¾ç½®çç¥ï¼ç´æ¥è¿é»è®¤çå¯ç çç¥ |
| | | String pwdStrategyId = userPasswordStrategyVOMap.get(oid); |
| | | if(Func.isNotBlank(pwdStrategyId)){ |
| | | //éè¿å¯ç çç¥oidå»mapä¸åå¯ç çç¥ |
| | | smPasswordStrategyVO = smPasswordStrategyVOMap.get(pwdStrategyId); |
| | | }else { |
| | | smPasswordStrategyVO = passwordStrategyVOByDefault; |
| | | } |
| | | returnMap.put(oid,smPasswordStrategyVO); |
| | | }); |
| | | return returnMap; |
| | | } |
| | | |
| | | } |