From ca2d9c7e8746f81ad9a0f19e2a1ca6515c7ac931 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期二, 25 六月 2024 10:20:39 +0800 Subject: [PATCH] 用户管理:停用、启用、修改、删除 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java | 486 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 396 insertions(+), 90 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java index 2df4e7e..2f5a410 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java @@ -1,12 +1,23 @@ package com.vci.frameworkcore.compatibility.impl; -import com.vci.client.common.providers.ServiceProvider; +import com.vci.client.common.objects.UserObject; +import com.vci.client.common.providers.ClientServiceProvider; import com.vci.common.util.ThreeDES; import com.vci.corba.common.PLException; +import com.vci.corba.framework.data.UserInfo; +import com.vci.corba.omd.data.BusinessObject; +import com.vci.frameworkcore.compatibility.OrgDeptQueryServiceI; +import com.vci.frameworkcore.compatibility.SmPwdStrategyQueryServiceI; +import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; import com.vci.frameworkcore.compatibility.SmUserQueryServiceI; +import com.vci.frameworkcore.dto.SmUserDTO; +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.enumpck.BooleanEnum; +import com.vci.starter.web.enumpck.UserSecretEnum; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.pagemodel.PageHelper; @@ -14,16 +25,18 @@ import com.vci.starter.web.pagemodel.TreeQueryObject; import com.vci.starter.web.util.BeanUtil; import com.vci.starter.web.util.VciBaseUtil; +import com.vci.starter.web.util.VciDateUtil; +import com.vci.starter.web.util.WebThreadLocalUtil; import com.vci.starter.web.wrapper.VciQueryWrapperForDO; +import com.vci.web.enumpck.UserTypeEnum; import com.vci.web.model.SmPasswordStrategyDO; import com.vci.web.model.SmUserDO; 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; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -31,8 +44,7 @@ import java.util.stream.Collectors; import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; -import static com.vci.web.constant.CacheNameConstant.VCI_USER; -import static com.vci.web.util.WebUtil.arryAndSqlToClientBusinessObject; +import static com.vci.web.util.WebUtil.arryAndSqlToBusinessObject; /** * 鐢ㄦ埛鐨勬煡璇㈢浉鍏崇殑鏈嶅姟锛屽彲浠ュ吋瀹硅�佸钩鍙板拰鑰佺殑pdm @@ -55,6 +67,24 @@ */ @Autowired private WebBoServiceI boService; + + /** + * 閮ㄩ棬鏈嶅姟 + */ + @Autowired + private OrgDeptQueryServiceI orgDeptQueryService; + + /** + * 瑙掕壊鏈嶅姟 + */ + @Autowired + private SmRoleQueryServiceI smRoleQueryService; + + /** + * 瀵嗙爜绛栫暐鏌ヨ鏈嶅姟 + */ + @Autowired + private SmPwdStrategyQueryServiceI smPwdStrategyQueryService; /** * 浣跨敤瑙掕壊鐨勫睘鎬ф煡璇㈢敤鎴锋椂 @@ -82,11 +112,39 @@ public static final String QUERY_FIELD_ROLE = "roleUser.plroleuid"; /** - * 鑷紩鐢� + * 鐢ㄦ埛鍒嗛〉鏌ヨ鏃惰幏鍙栭儴闂ㄦ斁鍒拌繖閲岄伩鍏嶉噸澶嶆煡璇� */ - @Autowired(required = false) - @Lazy - private SmUserQueryServiceI self; + private Map<String,List<OrgDepartmentVO>> orgDepartmentVOMap; + + /** + * 鐢ㄦ埛鍒嗛〉鏌ヨ鏃惰幏鍙栬鑹叉斁鍒拌繖閲岄伩鍏嶉噸澶嶆煡璇� + */ + private Map<String,List<SmRoleVO>> smRoleVOMap; + + /** + * 鐢ㄦ埛鍒嗛〉鏌ヨ鏃惰幏鍙栧瘑鐮佺瓥鐣ユ斁鍒拌繖閲岄伩鍏嶅娆℃煡璇� + */ + private Map<String,SmPasswordStrategyVO> smPwdStrategyVOMap; + + /** + * 妫�鏌ョ敤鎴锋槸鍚﹀瓨鍦紝鍙互鏍规嵁鐢ㄦ埛鍚嶏紝涔熷彲浠ユ牴鎹敤鎴穙id + * @param userName 浼爊ull锛屽嵆鐢╫id浣滀负妫�鏌ユ潯浠� + * @param oid 浼爊ull锛屽嵆鐢╱serName浣滀负妫�鏌ユ潯浠� + * @return true瀛樺湪锛宖alse涓嶅瓨鍦� + */ + @Override + public boolean checkUserExist(String userName, String oid) throws PLException { + if(Func.isEmpty(userName) && Func.isEmpty(oid)){ + throw new PLException("妫�鏌ョ敤鎴锋槸鍚﹀瓨鍦ㄦ椂锛屼紶閫掔殑鍙傛暟鐢ㄦ埛鍚嶅拰鐢ㄦ埛oid閮戒负绌猴紒",new String[0]); + } + UserInfo userInfo = null; + if(Func.isNotEmpty(userName)) { + userInfo = platformClientUtil.getFrameworkService().getUserObjectByUserName(userName); + }else{ + userInfo = platformClientUtil.getFrameworkService().getUserObjectByoid(oid); + } + return Func.isNotEmpty(userInfo); + } /** * 鏍规嵁鐢ㄦ埛鍚嶈幏鍙栫敤鎴风殑瀵硅薄锛屼笉鍖哄垎澶у皬鍐� @@ -95,10 +153,14 @@ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - @Cacheable(value = VCI_USER,key = "#p0",unless = "#result == null") public SmUserVO getUserByUserId(String userId) throws VciBaseException { WebUtil.alertNotNull(userId,"鐢ㄦ埛鍚�"); - return getUserByField("plusername",userId); + try { + UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByUserName(userId); + return userInfo2VO(userInfo); + } catch (PLException e) { + throw new VciBaseException("鐧诲綍鏃讹紝鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛�"+e.getMessage()); + } } /** @@ -120,9 +182,9 @@ " left join PLUSERPASSWORDSTRATEGY pkUserPassword on " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " + queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):""); try{ - String[][] sqlQueryResult = ServiceProvider.getBOFService().getSqlQueryResult(sql + fromSql, null); + String[][] sqlQueryResult = platformClientUtil.getBOFService().getSqlQueryResult(sql + fromSql, null); if(sqlQueryResult.length>0){ - com.vci.client.bof.ClientBusinessObject cbo = arryAndSqlToClientBusinessObject(queryWrapper.getSelectFieldSql(),sqlQueryResult[0]); + BusinessObject cbo = arryAndSqlToBusinessObject(queryWrapper.getSelectFieldSql(),sqlQueryResult[0]); return cbo2VO(cbo); } }catch (Exception e){ @@ -150,7 +212,7 @@ + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on up.pldeptuid = pkDepartment.pluid " + " left join PLUSERPASSWORDSTRATEGY pkUserPassword on " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " + queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):""); - List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null); + List<BusinessObject> dataList = boService.queryBySql(sql + fromSql, null); if(!CollectionUtils.isEmpty(dataList)){ dataList.stream().forEach(cbo->{ userVOList.add(cbo2VO(cbo)); @@ -169,7 +231,12 @@ @Override public List<SmUserVO> listUserByUserIds(Collection<String> userIdCollections)throws VciBaseException { WebUtil.alertNotNull(userIdCollections,"鐢ㄦ埛鍚嶉泦鍚�"); - return listUserByField("plusername",userIdCollections); + try { + UserInfo[] userInfo = platformClientUtil.getFrameworkService().fetchUserInfoByNames(VciBaseUtil.collection2StrArr(userIdCollections)); + return userInfoArr2VO(userInfo); + } catch (PLException e) { + throw new VciBaseException("鑾峰彇鐢ㄦ埛澶辫触锛�"+e.getMessage()); + } } /** * 鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇鐢ㄦ埛鐨勪俊鎭� @@ -180,8 +247,14 @@ @Override public SmUserVO getUserByUserOid(String userOid) throws VciBaseException { WebUtil.alertNotNull(userOid,"鐢ㄦ埛涓婚敭"); - return getUserByField("pluid",userOid); + try { + UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByoid(userOid); + return userInfo2VO(userInfo); + } catch (PLException e) { + throw new VciBaseException("鑾峰彇鐢ㄦ埛澶辫触锛�"+e.getMessage()); + } } + /** * 鎵归噺鑾峰彇鐢ㄦ埛鐨勪俊鎭� 锛堟牴鎹敤鎴蜂富閿級 * @param userOidCollections 鐢ㄦ埛涓婚敭鐨勯泦鍚堬紝鍙互瓒呰繃1000涓� @@ -189,10 +262,84 @@ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - public List<SmUserVO> listUserByUserOids( - Collection<String> userOidCollections) throws VciBaseException { + public List<SmUserVO> listUserByUserOids(Collection<String> userOidCollections) throws VciBaseException { WebUtil.alertNotNull(userOidCollections,"鐢ㄦ埛涓婚敭闆嗗悎"); - return listUserByField("pluid",userOidCollections); + try { + UserInfo[] userInfoArr = platformClientUtil.getFrameworkService().getUserObjectByoids(VciBaseUtil.collection2StrArr(userOidCollections)); + return userInfoArr2VO(userInfoArr); + } catch (PLException e) { + throw new VciBaseException("鑾峰彇鐢ㄦ埛淇℃伅澶辫触:"+e.getMessage()); + } + } + + /** + * 涓氬姟鏁版嵁鏁扮粍杞樉绀哄璞¢泦鍚� + * @param userInfoArr 涓氬姟鏁版嵁鏁扮粍 + * @return 鏄剧ず瀵硅薄闆嗗悎 + */ + private List<SmUserVO> userInfoArr2VO(UserInfo[] userInfoArr) { + List<SmUserVO> userVOList = new ArrayList<>(); + for(UserInfo userInfo : userInfoArr){ + userVOList.add(userInfo2VO(userInfo)); + } + return userVOList; + } + + /** + * 涓氬姟鏁版嵁杞崲涓烘樉绀哄璞� + * @param userInfo 骞冲彴杩斿洖鐨勪笟鍔℃暟鎹� + * @return 鐢ㄦ埛鏄剧ず瀵硅薄 + */ + private SmUserVO userInfo2VO(UserInfo userInfo) { + SmUserVO smUserVO = new SmUserVO(); + smUserVO.setOid(userInfo.id); + smUserVO.setId(userInfo.userName); + smUserVO.setName(userInfo.trueName); + smUserVO.setSecretGrade(userInfo.secretGrade); + smUserVO.setSecretGradeText(UserSecretEnum.getSecretText(smUserVO.getSecretGrade())); + smUserVO.setUserType(String.valueOf(userInfo.userType)); + smUserVO.setUserTypeText(UserTypeEnum.getTextByValue(smUserVO.getUserType())); + smUserVO.setDescription(userInfo.desc); + smUserVO.setEmail(userInfo.email); + //鐢ㄦ埛鎵�灞為儴闂ㄧ殑鏌ヨ璁剧疆 + List<OrgDepartmentVO> orgDepartmentVOList = orgDepartmentVOMap.get(userInfo.id); + smUserVO.setPkDepartment( + Func.isEmpty(orgDepartmentVOList) ? + null:orgDepartmentVOList.stream().map(OrgDepartmentVO::getOid).collect(Collectors.joining(",")) + ); + smUserVO.setPkDepartmentName( + Func.isEmpty(orgDepartmentVOList) ? + null:orgDepartmentVOList.stream().map(OrgDepartmentVO::getName).collect(Collectors.joining(",")) + ); + //瀵嗙爜绛栫暐鏌ヨ璁剧疆 + SmPasswordStrategyVO smPasswordStrategyVO = smPwdStrategyVOMap.getOrDefault(userInfo.id,new SmPasswordStrategyVO()); + smUserVO.setPkPasswordStrategy(smPasswordStrategyVO.getOid()); + smUserVO.setPkPasswordStrategyName(smPasswordStrategyVO.getName()); + //瑙掕壊鏌ヨ璁剧疆 + List<SmRoleVO> smRoleVOList = smRoleVOMap.get(userInfo.id); + smUserVO.setPkPerson( + Func.isEmpty(smRoleVOList) ? + null:smRoleVOList.stream().map(SmRoleVO::getOid).collect(Collectors.joining(",")) + ); + smUserVO.setPkPersonName( + Func.isEmpty(smRoleVOList) ? + null:smRoleVOList.stream().map(SmRoleVO::getName).collect(Collectors.joining(",")) + ); + //鏄惁閮ㄩ棬棰嗗 + smUserVO.setIsDeptLeader(userInfo.isDeptLeader.equals("0") ? "涓嶆槸":"鏄�"); + //涓撲笟 + smUserVO.setSpecialties(userInfo.specialties); + if(userInfo.status == 0){ + smUserVO.setLockFlag(false); + }else{ + smUserVO.setLockFlag(true); + } + smUserVO.setCreator(userInfo.createUser); + smUserVO.setCreateTime(VciDateUtil.long2Date(userInfo.createTime)); + smUserVO.setLastModifier(userInfo.updateUser); + smUserVO.setLastLoginTime(VciDateUtil.long2Date(userInfo.updateTime)); + smUserVO.setLastModifyPasswordTime(VciDateUtil.long2Date(userInfo.pwdUpdateTime)); + return smUserVO; } /** @@ -203,11 +350,20 @@ private List<SmUserVO> smUserDO2VOs(List<SmUserDO> userDOS){ List<SmUserVO> userVOList = new ArrayList<>(); Optional.ofNullable(userDOS).orElseGet(()->new ArrayList<>()).stream().forEach(userDO->{ - SmUserVO userVO = new SmUserVO(); - BeanUtil.convert(userDO,userVO); - userVOList.add(userVO); + userVOList.add(smUserDO2VO(userDO)); }); return userVOList; + } + + /** + * 鐢ㄦ埛鐨勬暟鎹璞¤浆鎹负鏄剧ず瀵硅薄 + * @param smUserDO + * @return + */ + private SmUserVO smUserDO2VO(SmUserDO smUserDO){ + SmUserVO smUserVO = new SmUserVO(); + BeanUtil.convert(smUserDO,smUserVO); + return smUserVO; } /** @@ -231,7 +387,7 @@ + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on up.pldeptuid = pkDepartment.pluid " + " left join PLUSERPASSWORDSTRATEGY pkUserPassword on " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " + (QUERY_FIELD_ROLE.equalsIgnoreCase(queryField)?roleSql:"") + queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):""); - List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null); + List<BusinessObject> dataList = boService.queryBySql(sql + fromSql, null); if(!CollectionUtils.isEmpty(dataList)){ dataList.stream().forEach(cbo->{ userVOList.add(cbo2VO(cbo)); @@ -245,7 +401,7 @@ * @param cbo 涓氬姟鏁版嵁 * @return 鏄剧ず瀵硅薄 */ - private SmUserVO cbo2VO(com.vci.client.bof.ClientBusinessObject cbo){ + private SmUserVO cbo2VO(BusinessObject cbo){ SmUserDO userDO = new SmUserDO(); SmUserVO userVO = new SmUserVO(); WebUtil.copyValueToObjectFromCbos(cbo,userDO); @@ -268,9 +424,9 @@ * @return 鐢ㄦ埛鐨勬樉绀哄璞$殑鍒楄〃 */ private DataGrid<SmUserVO> gridUserByQueryField(String queryField,String queryValue, Map<String, String> queryMap, PageHelper pageHelper,boolean notIn){ - if(StringUtils.isBlank(queryValue)){ + /*if(StringUtils.isBlank(queryValue)){ return new DataGrid<>(); - } + }*/ PageHelper newPageHelper = new PageHelper(-1); newPageHelper.setSort(pageHelper.getSort()); newPageHelper.setOrder(pageHelper.getOrder()); @@ -299,7 +455,7 @@ } } } - List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql((isPage?("select " + pageSelectList.stream().collect(Collectors.joining(","))+ " from (select A.*,rownum RN from ( "):"") + sql + fromSql + (isPage?pageSubfix:""), null); + List<BusinessObject> dataList = boService.queryBySql((isPage?("select " + pageSelectList.stream().collect(Collectors.joining(","))+ " from (select A.*,rownum RN from ( "):"") + sql + fromSql + (isPage?pageSubfix:""), null); if(!CollectionUtils.isEmpty(dataList)){ dataList.stream().forEach(cbo->{ userVOList.add(cbo2VO(cbo)); @@ -313,6 +469,7 @@ } return dataGrid; } + /** * 鑾峰彇鐢ㄦ埛鐨勫垪琛紝榛樿浼氫互鐢ㄦ埛鍚嶅崌搴忔帓鍒楋紝鐢ㄦ埛鐨勭紪杈戦〉闈㈠垪琛ㄤ笉瑕佷娇鐢ㄨ繖涓帴鍙� * @param queryMap 鏌ヨ鏉′欢 @@ -324,6 +481,49 @@ public DataGrid<SmUserVO> gridUsers(Map<String, String> queryMap, PageHelper pageHelper) throws VciBaseException { return gridUserByQueryField(null,null,queryMap,pageHelper,false); + } + + /** + * 鐢ㄦ埛绠$悊鐣岄潰鍒嗛〉鏌ヨ + * @param conditionMap 鏌ヨ鏉′欢 + * @param pageHelper 鍒嗛〉鍙傛暟 + * @return + */ + @Override + public DataGrid<SmUserVO> getDataGridUsers(Map<String, String> conditionMap, PageHelper pageHelper) throws PLException { + if(pageHelper == null){ + pageHelper = new PageHelper(-1); + } + pageHelper.addDefaultAsc("PLTRUENAME"); + //String userName = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserName(); + //鍒嗛〉鏌ヨ + UserInfo[] userInfos = platformClientUtil.getFrameworkService().fetchUserInfoByCondition( + conditionMap.get("name"), + conditionMap.get("userName"), + conditionMap.get("deptId"), + conditionMap.get("roleId"), + "developer", //褰撳墠鐧诲綍鐨勭敤鎴峰悕 + pageHelper.getPage(), + pageHelper.getLimit() + ); + DataGrid<SmUserVO> dataGrid = new DataGrid<>(); + if(Func.isNotEmpty(userInfos)){ + List<String> idList = Arrays.stream(userInfos).map(item -> item.id).collect(Collectors.toList()); + orgDepartmentVOMap = orgDeptQueryService.batchListDeptByUserOids(idList, null); + smRoleVOMap = smRoleQueryService.batchListRoleByUserOids(idList,null); + smPwdStrategyVOMap = smPwdStrategyQueryService.batchSmPwdStrategyByUserOids(idList); + dataGrid.setData(userInfoArr2VO(userInfos)); + dataGrid.setTotal( + platformClientUtil.getFrameworkService().getUserTotalByCondition( + conditionMap.get("name"), + conditionMap.get("userName"), + conditionMap.get("deptId"), + conditionMap.get("roleId"), + "developer" //褰撳墠鐧诲綍鐨勭敤鎴峰悕 + ) + ); + } + return dataGrid; } /** @@ -354,7 +554,7 @@ */ @Override public String getUserNameByUserId(String userId) { - SmUserVO userVO = self.getUserByUserId(userId); + SmUserVO userVO = getUserByUserId(userId); return userVO == null?"":userVO.getName(); } /** @@ -364,11 +564,9 @@ */ @Override public String getUserNameByUserOid(String userOid) { - SmUserVO userVO = self.getUserByUserOid(userOid); + SmUserVO userVO = getUserByUserOid(userOid); return userVO.getName(); } - - /** * 鏌ヨ鏌愪釜閮ㄩ棬涓嬬殑鐢ㄦ埛瀵硅薄 @@ -387,7 +585,7 @@ } /** - * 鑾峰彇 + * 鑾峰彇鏌ヨ灏佽鍣紝榛樿鍙煡浜唒lstatus=0鍜宲lusertype=2锛屾帓搴忛粯璁lusername * @param queryField 鏌ヨ灞炴�� * @param queryValue 鏌ヨ鐨勫�� * @param queryMap 鏌ヨ鏉′欢锛屽鏋滄槸瑙掕壊鐨勫睘鎬э紝闇�瑕佷娇鐢╬krole.xxx @@ -422,6 +620,43 @@ queryWrapperForDO.setDistinct(true); return queryWrapperForDO; } + + /** + * 鑾峰彇鏌ヨ灏佽鍣紝榛樿鍙煡plusertype!=1鐨� + * @param queryField 鏌ヨ灞炴�� + * @param queryValue 鏌ヨ鐨勫�� + * @param queryMap 鏌ヨ鏉′欢锛屽鏋滄槸瑙掕壊鐨勫睘鎬э紝闇�瑕佷娇鐢╬krole.xxx + * @param pageHelper 鍒嗛〉瀵硅薄 + * @param notIn 鏄惁涓轰笉鍖呭惈 + * @return 鏌ヨ灏佽鍣� + */ + private VciQueryWrapperForDO getQueryWrapper2(String queryField,String queryValue,Map<String,String> queryMap,PageHelper pageHelper,boolean notIn){ + if(pageHelper == null){ + pageHelper = new PageHelper(-1); + } + pageHelper.addDefaultAsc("plusername"); + VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(queryMap,SmUserDO.class,pageHelper); + if(StringUtils.isNotBlank(queryField)) { + if (queryValue.contains(",")) { + if (notIn) { + queryWrapperForDO.notIn(queryField, VciBaseUtil.toInSql(VciBaseUtil.str2List(queryValue).toArray(new String[0]))); + } else { + queryWrapperForDO.in(queryField, VciBaseUtil.toInSql(VciBaseUtil.str2List(queryValue).toArray(new String[0]))); + } + } else { + if (notIn) { + queryWrapperForDO.neq(queryField, queryValue); + } else { + queryWrapperForDO.eq(queryField, queryValue); + } + } + } + addRoleQuerySql(queryMap,queryWrapperForDO); + queryWrapperForDO.neq("plusertype", "2"); + queryWrapperForDO.setDistinct(true); + return queryWrapperForDO; + } + /** * 鏌ヨ鏌愪釜閮ㄩ棬涓嬬殑鐢ㄦ埛瀵硅薄鍒楄〃 * @param deptOid 閮ㄩ棬鐨勪富閿� @@ -436,6 +671,7 @@ throws VciBaseException { return gridUserByQueryField(QUERY_FIELD_DEPARTMENT,deptOid,queryMap,pageHelper,false); } + /** * 鎵归噺鏍规嵁閮ㄩ棬鐨勪富閿幏鍙栫敤鎴� * @param deptOidCollection 閮ㄩ棬鐨勪富閿泦鍚� @@ -454,6 +690,7 @@ } return new HashMap<>(); } + /** * 鏌ヨ涓嶅湪鏌愪釜閮ㄩ棬涓嬬殑鐢ㄦ埛瀵硅薄鍒楄〃 * @param deptOid 閮ㄩ棬鐨勪富閿� @@ -469,6 +706,7 @@ } return listUserByQueryField(QUERY_FIELD_DEPARTMENT,deptOid,queryMap,true); } + /** * 鏌ヨ涓嶅湪鏌愪釜閮ㄩ棬涓嬬殑鐢ㄦ埛瀵硅薄鍒楄〃 * @param deptOid 閮ㄩ棬鐨勪富閿� @@ -483,6 +721,7 @@ throws VciBaseException { return gridUserByQueryField(QUERY_FIELD_DEPARTMENT,deptOid,queryMap,pageHelper,true); } + /** * 鏌ヨ鏌愪釜瑙掕壊涓嬬殑鐢ㄦ埛瀵硅薄 * @param roleOid 瑙掕壊鐨勪富閿� @@ -499,6 +738,7 @@ return listUserByQueryField(QUERY_FIELD_ROLE,roleOid,queryMap,false); } + /** * 鏌ヨ鏌愪釜瑙掕壊涓嬬殑鐢ㄦ埛瀵硅薄鍒楄〃 * @param roleOid 瑙掕壊鐨勪富閿� @@ -513,6 +753,7 @@ throws VciBaseException { return gridUserByQueryField(QUERY_FIELD_ROLE,roleOid,queryMap,pageHelper,false); } + /** * 鏌ヨ涓嶅湪鏌愪釜瑙掕壊涓嬬殑鐢ㄦ埛瀵硅薄鍒楄〃 * @param roleOid 瑙掕壊鐨勪富閿� @@ -528,6 +769,7 @@ } return listUserByQueryField(QUERY_FIELD_ROLE,roleOid,queryMap,true); } + /** * 鏌ヨ涓嶅湪鏌愪釜瑙掕壊涓嬬殑鐢ㄦ埛瀵硅薄鍒楄〃 * @param roleOid 瑙掕壊鐨勪富閿� @@ -542,6 +784,7 @@ throws VciBaseException { return gridUserByQueryField(QUERY_FIELD_ROLE,roleOid,queryMap,pageHelper,true); } + /** * 鎵归噺鏍规嵁瑙掕壊鐨勪富閿幏鍙栫敤鎴� * @param roleOidCollection 瑙掕壊鐨勪富閿泦鍚� @@ -599,6 +842,7 @@ PageHelper pageHelper) throws VciBaseException { return gridUserByQueryField(null,null,queryMap,pageHelper,false); } + /** * 鍙傜収鐢ㄦ埛鐨勬爲褰㈡樉绀� * @param treeQueryObject 鏍戝瀷鎺ュ彛鏌ヨ瀵硅薄 @@ -615,13 +859,13 @@ + " left join pluserdept up on " + queryWrapper.getTableNick() + ".pluid = up.pluseruid left join pldept pkDepartment on up.pldeptuid = pkDepartment.pluid " + " left join PLUSERPASSWORDSTRATEGY pkUserPassword on " +queryWrapper.getTableNick() + ".pluid = pkUserPassword.pluseruid " + queryWrapper.getLinkTableSql() + (StringUtils.isNotBlank(queryWrapper.getWhereSql())?(" where " + queryWrapper.getWhereSql()):""); - List<com.vci.client.bof.ClientBusinessObject> dataList = boService.queryBySql(sql + fromSql, null); + List<BusinessObject> dataList = boService.queryBySql(sql + fromSql, null); List<Tree> treeList = new ArrayList<>(); if(!CollectionUtils.isEmpty(dataList)){ dataList.stream().forEach(cbo->{ Tree tree = new Tree(); - tree.setOid(cbo.getOid()); - tree.setText(cbo.getId() + " " + cbo.getName()); + tree.setOid(cbo.oid); + tree.setText(cbo.id + " " + cbo.name); Map<String,String> attributeMap = new HashMap<>(); WebUtil.copyValueToCboFromMap(cbo,attributeMap); tree.setAttributes(attributeMap); @@ -631,6 +875,7 @@ } return treeList; } + /** * 鏍¢獙瀵嗙爜鏄惁鐩稿悓锛屽湪鏂板钩鍙颁腑瀛樺偍鐨勫瘑鐮佹槸涓ゆmd5 * @param userOid 鐢ㄦ埛涓婚敭 @@ -645,19 +890,20 @@ String sql = " select plpassword from pluser where pluid = :userOid"; Map<String,String> conditionMap = new HashMap<>(); conditionMap.put("userOid",userOid.trim()); - List<com.vci.client.bof.ClientBusinessObject> clientBusinessObjectList = boService.queryBySql(sql, conditionMap); - if(CollectionUtils.isEmpty(clientBusinessObjectList)){ + List<BusinessObject> BusinessObjectList = boService.queryBySql(sql, conditionMap); + if(CollectionUtils.isEmpty(BusinessObjectList)){ return false; } ThreeDES des = new ThreeDES();// 瀹炰緥鍖栦竴涓锟�? des.getKey("daliantan0v0");// 鐢熸垚瀵嗗寵 md5Password = des.getEncString(md5Password); - if(md5Password.equals(clientBusinessObjectList.get(0).getAttributeValue("plpassword"))){ + if(md5Password.equals(ObjectTool.getNewBOAttributeValue(BusinessObjectList.get(0),"plpassword"))){ return true; } return false; } + /** * 鏍¢獙鐢ㄦ埛鏄惁閿佸畾 * @param smUserVO 鐢ㄦ埛瀵硅薄 @@ -670,7 +916,9 @@ return smUserVO.isLockFlag(); } //鏌ヨ瀵嗙爜绛栫暐 - SmPasswordStrategyVO passwordStrategyVO = getPasswordStrategyVOByOid(smUserVO.getPkPasswordStrategy()); + SmPasswordStrategyVO passwordStrategyVO = smPwdStrategyQueryService.getPasswordStrategyVOByOid( + smUserVO.getPkPasswordStrategy() + ); if(passwordStrategyVO == null){ throw new VciBaseException("绯荤粺閲屾病鏈夊瘑鐮佸畨鍏ㄧ瓥鐣�"); } @@ -680,57 +928,6 @@ return false; } - /** - * 浣跨敤涓婚敭鑾峰彇瀵嗙爜绛栫暐 - * @param oid 涓婚敭 - * @return 瀵嗙爜绛栫暐鏄剧ず瀵硅薄 - */ - public SmPasswordStrategyVO getPasswordStrategyVOByOid(String oid){ - VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null, SmPasswordStrategyDO.class); - queryWrapperForDO.eq("oid",oid.trim()); - List<com.vci.client.bof.ClientBusinessObject> 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); - SmPasswordStrategyVO passwordStrategyVO = new SmPasswordStrategyVO(); - BeanUtil.convert(passwordStrategyDO,passwordStrategyVO); - return passwordStrategyVO; - } - } - return null; - } - - /** - * 鏍规嵁鐢ㄦ埛鐨勪富閿紝鑾峰彇鐢ㄦ埛鐨勫瘑鐮佸畨鍏ㄧ瓥鐣� - * @param userOid 鐢ㄦ埛鐨勪富閿� - * @return 瀵嗙爜瀹夊叏绛栫暐鐨勬樉绀哄璞★紝濡傛灉涓嶅瓨鍦ㄥ垯浼氳繑鍥濶ull - * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 - */ - @Override - public SmPasswordStrategyVO getPasswordStrategyVOByUserOid(String userOid) - throws VciBaseException { - WebUtil.alertNotNull(userOid,"鐢ㄦ埛鐨勪富閿�"); - SmUserVO userVO = getUserByUserOid(userOid); - if(userVO == null || StringUtils.isBlank(userVO.getOid())){ - throw new VciBaseException(DATA_OID_NOT_EXIST); - } - return getPasswordStrategyVOByOid(userVO.getPkPasswordStrategy()); - } /** * 璁剧疆鏌愪釜鐢ㄦ埛鏄攣瀹氱姸鎬� @@ -740,6 +937,7 @@ public void lockUser(String userId) { //鑰佺殑杩欎釜骞冲彴锛屾槸渚濋潬閿佸畾娆℃暟鏉ュ垽鏂殑锛屾墍浠ヨ繖閲屾病鍔炴硶鐩存帴璁剧疆 } + /** * 璁剧疆鏌愪釜鐢ㄦ埛涓嶆槸閿佸畾鐘舵�� * @param userId 鐢ㄦ埛鍚� @@ -754,6 +952,7 @@ throw WebUtil.getVciBaseException(vciError); } } + /** * 淇敼瀵嗙爜 * @param userOid 鐢ㄦ埛涓婚敭 @@ -777,6 +976,7 @@ throw WebUtil.getVciBaseException(vciError); } } + /** * 鏇存柊鐢ㄦ埛鐨勫瘑鐮侀敊璇鏁� * @param userOid 鐢ㄦ埛鐨勪富閿� @@ -794,6 +994,7 @@ throw WebUtil.getVciBaseException(vciError); } } + /** * 鏇存柊鐢ㄦ埛鐨勬渶鍚庣櫥褰曟椂闂� * @param userOid 鐢ㄦ埛鐨勪富閿� @@ -809,4 +1010,109 @@ throw WebUtil.getVciBaseException(vciError); } } + + /** + * 娣诲姞鐢ㄦ埛 + * @param smUserDTO + * @return + */ + @Override + public boolean addUser(SmUserDTO smUserDTO) throws PLException { + VciBaseUtil.alertNotNull( + smUserDTO,"娣诲姞鐨勭敤鎴峰璞�", + smUserDTO.getId(),"璐﹀彿", + smUserDTO.getPassword(),"瀵嗙爜", + smUserDTO.getConfirmPassword(),"纭瀵嗙爜", + smUserDTO.getName(),"濮撳悕" + ); + //纭瀵嗙爜 + String confirmPassword = smUserDTO.getConfirmPassword(); + //姣斿瀵嗙爜鏄槸鍚︿竴鑷� + if(!smUserDTO.getPassword().equals(confirmPassword)){ + throw new VciBaseException("涓ゆ瀵嗙爜涓嶄竴鑷达紝璇烽噸鏂板~鍐�!"); + } + //鍏堢敤鎴峰悕锛堣处鍙凤級鏌ラ噸 + SmUserVO dbSmUserVO = getUserByUserId(smUserDTO.getId()); + if(Func.isNotEmpty(dbSmUserVO) && Func.isNotBlank(dbSmUserVO.getOid())){ + throw new VciBaseException("璇ョ敤鎴峰悕鍦ㄧ郴缁熶腑宸茬粡瀛樺湪,璇蜂慨鏀�!"); + } + //瀵嗙爜鍔犲瘑 + ThreeDES des = new ThreeDES(); + des.getKey("daliantan0v0");// 鐢熸垚瀵嗗寵 + //绗簩娆D5鍔犲瘑 + String md5Password2 = des.getEncString(smUserDTO.getPassword()); + //鐢熸垚瀛樺偍鐨凞O瀵硅薄 + smUserDTO.setOid(VciBaseUtil.getPk()); + smUserDTO.setPassword(md5Password2); + smUserDTO.setLockFlag("0"); + BusinessObject user = ClientServiceProvider.getBOFService().initBusinessObject("user"); + SmUserDO smUserDO = new SmUserDO(); + BeanUtil.convert(user,smUserDO); + UserInfo userInfo = new UserInfo(); + BeanUtil.convert(smUserDO,userInfo); + return platformClientUtil.getFrameworkService().saveOrUpdateUser(userInfo, null); + } + + /** + * 淇敼鐢ㄦ埛 + * @param smUserDTO + * @return + */ + @Override + public boolean updateUser(SmUserDTO smUserDTO) throws PLException { + UserInfo userInfo = new UserInfo(); + BeanUtil.convert(smUserDTO,userInfo); + return platformClientUtil.getFrameworkService().updateUser(userInfo, null); + } + + /*** + * 鐢ㄦ埛浠庡鎴风瀵硅薄鍒癱orba瀵硅薄 + * + * @param user + * @return + */ + public UserInfo changeUserObjectToUserInfo(UserObject user) { + UserInfo userInfo = new UserInfo(); + userInfo.id = user.getId() == null ? "" : user.getId(); + userInfo.userName = user.getUserName() == null ? "" : user.getUserName(); + userInfo.pwd = user.getPwd() == null ? "" : user.getPwd(); + userInfo.trueName = user.getTrueName() == null ? "" : user.getTrueName(); + userInfo.specialties = user.getSpecialties() == null ? "" : user.getSpecialties(); + userInfo.email = user.getEmail() == null ? "" : user.getEmail(); + userInfo.desc = user.getDesc() == null ? "" : user.getDesc(); + userInfo.userType = user.getUserType(); + userInfo.status = user.getStatus(); + userInfo.createTime = user.getCreateTime(); + userInfo.createUser = user.getCreateUser() == null ? "" : user.getCreateUser(); + userInfo.updateTime = user.getUpdateTime(); + userInfo.updateUser = user.getUpdateUser() == null ? "" : user.getUpdateUser(); + userInfo.pwdUpdateTime = user.getPwdUpdateTime(); + userInfo.grantor = user.getGrantor() == null ? "" : user.getGrantor(); + userInfo.isDeptLeader = user.getIsDeptLeader() == null ? "0" : user.getIsDeptLeader(); + return userInfo; + } + + /** + * 鍒犻櫎鐢ㄦ埛 + * @param ids + * @return + */ + @Override + public boolean deleteUser(String[] ids) throws PLException { + VciBaseUtil.alertNotNull(ids,"寰呭垹闄ょ殑鐢ㄦ埛id鍒楄〃涓嶈兘涓虹┖锛�"); + return platformClientUtil.getFrameworkService().deleteUser(ids, null); + } + + /** + * 鐢ㄦ埛鍋滅敤/鍚敤 + * @param ids + * @param flag + * @return + */ + @Override + public boolean disableOrEnableUsers(String[] ids, boolean flag) throws PLException { + VciBaseUtil.alertNotNull(ids,"鍋滅敤/鍚敤鐨勭敤鎴穒d鍒楄〃"); + return platformClientUtil.getFrameworkService().stopUsers(ids, flag,null); + } + } -- Gitblit v1.9.3