!28 获取用户信息时补全组织机构名称和职位名称

Merge pull request !28 from 叶星/dev-7.2.2
pull/29/head
stylefeng 2022-03-08 14:05:08 +00:00 committed by Gitee
commit 0b0246a276
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 62 additions and 6 deletions

View File

@ -45,4 +45,10 @@ public interface OrganizationServiceApi {
*/ */
List<HrOrganizationDTO> orgList(); List<HrOrganizationDTO> orgList();
/**
*
* @param orgId
* @return
*/
HrOrganizationDTO getOrgDetail(Long orgId);
} }

View File

@ -1,5 +1,7 @@
package cn.stylefeng.roses.kernel.system.api; package cn.stylefeng.roses.kernel.system.api;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionDTO;
/** /**
* api * api
* *
@ -16,4 +18,10 @@ public interface PositionServiceApi {
*/ */
Integer positionNum(); Integer positionNum();
/**
*
* @param positionId
* @return
*/
HrPositionDTO getPositionDetail(Long positionId);
} }

View File

@ -113,6 +113,12 @@ public class SysUserDTO {
@ChineseDescription("用户所属机构") @ChineseDescription("用户所属机构")
private Long orgId; private Long orgId;
/**
*
*/
@ChineseDescription("用户所属机构名称")
private String orgName;
/** /**
* *
*/ */

View File

@ -25,6 +25,7 @@
package cn.stylefeng.roses.kernel.system.modular.organization.service.impl; package cn.stylefeng.roses.kernel.system.modular.organization.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
@ -334,6 +335,18 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
return list.stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList()); return list.stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList());
} }
@Override
public HrOrganizationDTO getOrgDetail(Long orgId) {
HrOrganizationDTO hrOrganizationDTO = new HrOrganizationDTO();
HrOrganizationRequest request = new HrOrganizationRequest();
request.setOrgId(orgId);
HrOrganization detail = this.detail(request);
if (ObjectUtil.isNotNull(detail)) {
BeanUtil.copyProperties(detail, hrOrganizationDTO, CopyOptions.create().ignoreError());
}
return hrOrganizationDTO;
}
/** /**
* wrapper * wrapper
* *

View File

@ -25,6 +25,7 @@
package cn.stylefeng.roses.kernel.system.modular.organization.service.impl; package cn.stylefeng.roses.kernel.system.modular.organization.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory; import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
@ -35,6 +36,7 @@ import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.system.api.UserOrgServiceApi; import cn.stylefeng.roses.kernel.system.api.UserOrgServiceApi;
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException; import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.api.exception.enums.organization.PositionExceptionEnum; import cn.stylefeng.roses.kernel.system.api.exception.enums.organization.PositionExceptionEnum;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionRequest; import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionRequest;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition; import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition;
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrPositionMapper; import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrPositionMapper;
@ -132,6 +134,18 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
return this.count(); return this.count();
} }
@Override
public HrPositionDTO getPositionDetail(Long positionId) {
HrPositionDTO hrPositionDTO = new HrPositionDTO();
HrPositionRequest request = new HrPositionRequest();
request.setPositionId(positionId);
HrPosition detail = this.detail(request);
if (ObjectUtil.isNotNull(detail)) {
BeanUtil.copyProperties(detail, hrPositionDTO, CopyOptions.create().ignoreError());
}
return hrPositionDTO;
}
/** /**
* id * id
* *

View File

@ -53,10 +53,7 @@ import cn.stylefeng.roses.kernel.rule.enums.TreeNodeEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict; import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory; import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
import cn.stylefeng.roses.kernel.system.api.DataScopeApi; import cn.stylefeng.roses.kernel.system.api.*;
import cn.stylefeng.roses.kernel.system.api.OrganizationServiceApi;
import cn.stylefeng.roses.kernel.system.api.ResourceServiceApi;
import cn.stylefeng.roses.kernel.system.api.RoleServiceApi;
import cn.stylefeng.roses.kernel.system.api.enums.DevopsCheckStatusEnum; import cn.stylefeng.roses.kernel.system.api.enums.DevopsCheckStatusEnum;
import cn.stylefeng.roses.kernel.system.api.enums.UserStatusEnum; import cn.stylefeng.roses.kernel.system.api.enums.UserStatusEnum;
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException; import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
@ -64,6 +61,7 @@ import cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserExceptio
import cn.stylefeng.roses.kernel.system.api.expander.SystemConfigExpander; import cn.stylefeng.roses.kernel.system.api.expander.SystemConfigExpander;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.DataScopeDTO; import cn.stylefeng.roses.kernel.system.api.pojo.organization.DataScopeDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO; import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.role.dto.SysRoleDTO; import cn.stylefeng.roses.kernel.system.api.pojo.role.dto.SysRoleDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.*; import cn.stylefeng.roses.kernel.system.api.pojo.user.*;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest; import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
@ -144,6 +142,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Resource @Resource
private CacheOperatorApi<SysUserDTO> sysUserCacheOperatorApi; private CacheOperatorApi<SysUserDTO> sysUserCacheOperatorApi;
@Resource
private PositionServiceApi positionServiceApi;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void add(SysUserRequest sysUserRequest) { public void add(SysUserRequest sysUserRequest) {
@ -388,8 +389,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 获取用户组织绑定信息 // 获取用户组织绑定信息
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId()); SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId());
sysUserResponse.setOrgId(userOrgInfo.getOrgId()); if (ObjectUtil.isNotNull(userOrgInfo.getOrgId())) {
sysUserResponse.setPositionId(userOrgInfo.getPositionId()); sysUserResponse.setOrgId(userOrgInfo.getOrgId());
HrOrganizationDTO orgDetail = organizationServiceApi.getOrgDetail(userOrgInfo.getOrgId());
sysUserResponse.setOrgName(orgDetail.getOrgName());
}
if (ObjectUtil.isNotNull(userOrgInfo.getPositionId())) {
sysUserResponse.setPositionId(userOrgInfo.getPositionId());
HrPositionDTO positionDetail = positionServiceApi.getPositionDetail(userOrgInfo.getPositionId());
sysUserResponse.setPositionName(positionDetail.getPositionName());
}
// 获取用户角色信息 // 获取用户角色信息
sysUserResponse.setGrantRoleIdList(sysUserRoleService.findRoleIdsByUserId(sysUser.getUserId())); sysUserResponse.setGrantRoleIdList(sysUserRoleService.findRoleIdsByUserId(sysUser.getUserId()));