| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.vci.client.common.providers.ServiceProvider; |
| | | 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.frameworkcore.compatibility.SmUserQueryServiceI; |
| | | import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO; |
| | | import com.vci.frameworkcore.pagemodel.SmUserVO; |
| | | 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; |
| | |
| | | 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.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.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | public static final String QUERY_FIELD_ROLE = "roleUser.plroleuid"; |
| | | |
| | | /** |
| | | * 自引用 |
| | | */ |
| | | @Autowired(required = false) |
| | | @Lazy |
| | | private SmUserQueryServiceI self; |
| | | |
| | | /** |
| | | * 根据用户名获取用户的对象,不区分大小写 |
| | | * @param userId 用户名 |
| | | * @return 用户的显示对象,如果用户不存在则返回null,不会抛出异常 |
| | |
| | | @Override |
| | | 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()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 业务数据转换为显示对象 |
| | | * @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); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | " 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 = ClientServiceProvider.getBOFService().getSqlQueryResult(sql + fromSql, null); |
| | | if(sqlQueryResult.length>0){ |
| | | com.vci.client.bof.ClientBusinessObject cbo = arryAndSqlToClientBusinessObject(queryWrapper.getSelectFieldSql(),sqlQueryResult[0]); |
| | | return cbo2VO(cbo); |
| | |
| | | @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()); |
| | | } |
| | | } |
| | | /** |
| | | * 根据用户主键获取用户的信息 |
| | |
| | | @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()); |
| | | } |
| | | } |
| | | /** |
| | | * 批量获取用户的信息 (根据用户主键) |
| | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public String getUserNameByUserId(String userId) { |
| | | SmUserVO userVO = self.getUserByUserId(userId); |
| | | SmUserVO userVO = getUserByUserId(userId); |
| | | return userVO == null?"":userVO.getName(); |
| | | } |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public String getUserNameByUserOid(String userOid) { |
| | | SmUserVO userVO = self.getUserByUserOid(userOid); |
| | | SmUserVO userVO = getUserByUserOid(userOid); |
| | | return userVO.getName(); |
| | | } |
| | | |