fix:查询用户列表

This commit is contained in:
2026-02-03 10:25:52 +08:00
parent f76f53507e
commit 28fddc4332
10 changed files with 104 additions and 1 deletions

View File

@@ -80,7 +80,7 @@ public class SpdmUserController {
@Operation(summary = "条件查询用户列表") @Operation(summary = "条件查询用户列表")
@PostMapping(value = "/listUser") @PostMapping(value = "/listUser")
public ResponseR listUser(@RequestBody UserPageQueryDto userPageQueryDto) { public ResponseR listUser(@RequestBody UserPageQueryDto userPageQueryDto) {
R<Page<StaffPageResultDto>> sysStaffPageR = remoteTenantServiceFeign.listStaffForPage( R<Page<StaffPageResultDto>> sysStaffPageR = remoteTenantServiceFeign.listStaffForPage2(
StaffPageQueryDto.builder() StaffPageQueryDto.builder()
.tenantId(userPageQueryDto.getTenantId()) .tenantId(userPageQueryDto.getTenantId())
.nickname(userPageQueryDto.getNickname()) .nickname(userPageQueryDto.getNickname())

View File

@@ -47,6 +47,9 @@ public interface RemoteTenantServiceFeign {
@GetMapping("/sysStaff/page") @GetMapping("/sysStaff/page")
R<Page<StaffPageResultDto>> listStaffForPage(@SpringQueryMap StaffPageQueryDto pageQueryDto, @RequestHeader(CommonConstants.TENANT_ID) String tenantIdHeader); R<Page<StaffPageResultDto>> listStaffForPage(@SpringQueryMap StaffPageQueryDto pageQueryDto, @RequestHeader(CommonConstants.TENANT_ID) String tenantIdHeader);
@GetMapping("/sysStaff/pageForSpdm")
R<Page<StaffPageResultDto>> listStaffForPage2(@SpringQueryMap StaffPageQueryDto pageQueryDto, @RequestHeader(CommonConstants.TENANT_ID) String tenantIdHeader);
@GetMapping("/sysStaff/findStaffListByUserId") @GetMapping("/sysStaff/findStaffListByUserId")
R<List<SysStaffVO>> findStaffListByUserId(@RequestParam Long userId, @RequestHeader(SecurityConstants.FROM) String from); R<List<SysStaffVO>> findStaffListByUserId(@RequestParam Long userId, @RequestHeader(SecurityConstants.FROM) String from);

View File

@@ -8,6 +8,7 @@ import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.common.feign.config.FeignConfig; import com.honeycombis.honeycom.common.feign.config.FeignConfig;
import com.honeycombis.honeycom.spdm.dto.UserPageQueryDto; import com.honeycombis.honeycom.spdm.dto.UserPageQueryDto;
import com.honeycombis.honeycom.spdm.dto.UserPageResultDto; import com.honeycombis.honeycom.spdm.dto.UserPageResultDto;
import com.honeycombis.honeycom.tenant.vo.SysUserOnTenantVO;
import com.honeycombis.honeycom.user.vo.SysUserInfoVO; import com.honeycombis.honeycom.user.vo.SysUserInfoVO;
import com.honeycombis.honeycom.user.vo.SysUserVO; import com.honeycombis.honeycom.user.vo.SysUserVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
@@ -32,4 +33,6 @@ public interface RemoteUserServiceFeign {
@GetMapping("/user/getUserListByIds") @GetMapping("/user/getUserListByIds")
R<List<SysUserVO>> getUserListByIds(@RequestParam("userIds") List<Long> userIds, @RequestHeader(SecurityConstants.FROM) String from, @RequestHeader(CommonConstants.TENANT_ID) String tenantId); R<List<SysUserVO>> getUserListByIds(@RequestParam("userIds") List<Long> userIds, @RequestHeader(SecurityConstants.FROM) String from, @RequestHeader(CommonConstants.TENANT_ID) String tenantId);
@PostMapping("/user/findStaffUserByIdsForSpdm")
R<List<SysUserOnTenantVO>> findStaffUserByIdsForSpdm(@RequestBody List<Long> userIds);
} }

View File

@@ -49,6 +49,13 @@ public class SysStaffController {
return R.ok(sysStaffService.page(page, sysStaffQueryDTO)); return R.ok(sysStaffService.page(page, sysStaffQueryDTO));
} }
@Inner(false)
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/pageForSpdm" )
public R<IPage<SysStaffDetailVO>> pageForSpdm(@ParameterObject Page<SysStaffEntity> page, @ParameterObject SysStaffQueryDTO sysStaffQueryDTO) {
return R.ok(sysStaffService.pageForSpdm(page, sysStaffQueryDTO));
}
@Operation(summary = "通过部门Id查询部门下包括子部门的员工列表" , description = "通过部门Id查询部门下包括子部门的员工列表" ) @Operation(summary = "通过部门Id查询部门下包括子部门的员工列表" , description = "通过部门Id查询部门下包括子部门的员工列表" )
@GetMapping("/retrieve/dept" ) @GetMapping("/retrieve/dept" )
public R<List<SysStaffDetailVO>> findByDeptId(@RequestParam(required = false) Long deptId) { public R<List<SysStaffDetailVO>> findByDeptId(@RequestParam(required = false) Long deptId) {

View File

@@ -35,6 +35,8 @@ public interface SysStaffService extends IService<SysStaffEntity> {
IPage<SysStaffDetailVO> page(Page<SysStaffEntity> page, SysStaffQueryDTO sysStaffQueryDTO); IPage<SysStaffDetailVO> page(Page<SysStaffEntity> page, SysStaffQueryDTO sysStaffQueryDTO);
IPage<SysStaffDetailVO> pageForSpdm(Page<SysStaffEntity> page, SysStaffQueryDTO sysStaffQueryDTO);
SysStaffDetailVO getStaffById(Long staffId); SysStaffDetailVO getStaffById(Long staffId);
void updateStaffById(SysStaffUpdateDTO sysStaffUpdateDTO); void updateStaffById(SysStaffUpdateDTO sysStaffUpdateDTO);

View File

@@ -448,6 +448,55 @@ public class SysStaffServiceImpl extends ServiceImpl<SysStaffMapper, SysStaffEnt
return result; return result;
} }
@Override
public IPage<SysStaffDetailVO> pageForSpdm(Page<SysStaffEntity> page, SysStaffQueryDTO sysStaffQueryDTO) {
if (Objects.isNull(page)) {
throw new HoneycomException(ErrorType.PARAM_ERROR.getCode());
}
LambdaQueryWrapper<SysStaffEntity> queryWrapper = new LambdaQueryWrapper<>();
if (!Objects.isNull(sysStaffQueryDTO)) {
if (StringUtils.isNotBlank(sysStaffQueryDTO.getStaffCode())) {
queryWrapper.like(SysStaffEntity::getStaffCode, sysStaffQueryDTO.getStaffCode());
}
if (StringUtils.isNotBlank(sysStaffQueryDTO.getEmail())) {
queryWrapper.like(SysStaffEntity::getEmail, sysStaffQueryDTO.getEmail());
}
if (ObjectUtil.isNotEmpty(sysStaffQueryDTO.getUserId())) {
queryWrapper.eq(SysStaffEntity::getUserId, sysStaffQueryDTO.getUserId());
}
if (StringUtils.isNotBlank(sysStaffQueryDTO.getNickname())) {
R<List<Long>> userIdListByNickNameLike = honeycomUserServiceFeign.getUserIdListByNickNameLike(sysStaffQueryDTO.getNickname(), SecurityConstants.FROM_IN);;
if (CollectionUtils.isNotEmpty(userIdListByNickNameLike.getData())) {
queryWrapper.in(SysStaffEntity::getUserId, userIdListByNickNameLike.getData());
} else {
queryWrapper.in(SysStaffEntity::getUserId, -1L);
}
}
if (!Objects.isNull(sysStaffQueryDTO.getTenantId())) {
queryWrapper.eq(SysStaffEntity::getTenantId, sysStaffQueryDTO.getTenantId());
} else {
queryWrapper.eq(SysStaffEntity::getTenantId, TenantContextHolder.getTenantId());
}
}
Page<SysStaffEntity> pageData = this.page(page, queryWrapper);
if (Objects.isNull(pageData)) {
throw new HoneycomException(UserErrorType.QUERY_USER_PAGE_ERROR.getCode());
}
IPage<SysStaffDetailVO> result = pageData.convert(SysStaffDetailVO::new);
List<SysStaffDetailVO> sysUserList = result.getRecords();
List<Long> userIds = sysUserList.stream().map(SysStaffDetailVO::getUserId).distinct().toList();
Map<Long, SysUserOnTenantVO> userMap = this.getMapStaffUserInfoForSpdm(userIds);
for (SysStaffDetailVO record : sysUserList) {
if (userMap.containsKey(record.getUserId())) {
record.setUserInfo(userMap.get(record.getUserId()));
}
}
return result;
}
private void setSysUserDetailInfo(List<SysStaffDetailVO> sysUserList) { private void setSysUserDetailInfo(List<SysStaffDetailVO> sysUserList) {
if (CollectionUtils.isNotEmpty(sysUserList)) { if (CollectionUtils.isNotEmpty(sysUserList)) {
List<Long> staffIds = sysUserList.stream().map(SysStaffDetailVO::getStaffId).distinct().toList(); List<Long> staffIds = sysUserList.stream().map(SysStaffDetailVO::getStaffId).distinct().toList();
@@ -488,6 +537,19 @@ public class SysStaffServiceImpl extends ServiceImpl<SysStaffMapper, SysStaffEnt
return userListR.getData().stream().collect(Collectors.toMap(SysUserOnTenantVO::getUserId, Function.identity(), (key1, key2) -> key2)); return userListR.getData().stream().collect(Collectors.toMap(SysUserOnTenantVO::getUserId, Function.identity(), (key1, key2) -> key2));
} }
private Map<Long, SysUserOnTenantVO> getMapStaffUserInfoForSpdm(List<Long> userIds) {
if (CollectionUtils.isEmpty(userIds)) {
throw new HoneycomException(ErrorType.PARAM_ERROR.getCode());
}
R<List<SysUserOnTenantVO>> userListR = honeycomUserServiceFeign.findStaffUserByIdsForSpdm(userIds, SecurityConstants.FROM_IN);
if (Objects.isNull(userListR) || !userListR.isSuccess() || CollectionUtils.isEmpty(userListR.getData())) {
throw new HoneycomException(TenantErrorType.USER_INFO_QUERY_FAILED.getCode());
}
return userListR.getData().stream().collect(Collectors.toMap(SysUserOnTenantVO::getUserId, Function.identity(), (key1, key2) -> key2));
}
@Override @Override
public SysStaffDetailVO getStaffById(Long staffId) { public SysStaffDetailVO getStaffById(Long staffId) {
if (Objects.isNull(staffId)) { if (Objects.isNull(staffId)) {

View File

@@ -45,6 +45,9 @@ public interface HoneycomUserServiceFeign {
@GetMapping("/user/findStaffUserByIds") @GetMapping("/user/findStaffUserByIds")
R<List<SysUserOnTenantVO>> findStaffUserByIds(@RequestParam("userIds") List<Long> userIds, @RequestHeader(SecurityConstants.FROM) String from); R<List<SysUserOnTenantVO>> findStaffUserByIds(@RequestParam("userIds") List<Long> userIds, @RequestHeader(SecurityConstants.FROM) String from);
@PostMapping("/user/findStaffUserByIdsForSpdm")
R<List<SysUserOnTenantVO>> findStaffUserByIdsForSpdm(@RequestBody List<Long> userIds, @RequestHeader(SecurityConstants.FROM) String from);
@GetMapping("/user/getUserIdListByNickNameLike") @GetMapping("/user/getUserIdListByNickNameLike")
R<List<Long>> getUserIdListByNickNameLike(@RequestParam("nickName") String nickName, @RequestHeader(SecurityConstants.FROM) String from); R<List<Long>> getUserIdListByNickNameLike(@RequestParam("nickName") String nickName, @RequestHeader(SecurityConstants.FROM) String from);

View File

@@ -197,6 +197,13 @@ public class SysUserController {
return R.ok(sysUserService.findStaffUserByIds(userIds)); return R.ok(sysUserService.findStaffUserByIds(userIds));
} }
@Inner(value = false)
@Operation(summary = "根据用户Id集合获取用户信息返回StaffUser" , description = "根据用户Id集合获取用户信息返回StaffUser" )
@PostMapping("/findStaffUserByIdsForSpdm")
public R<List<SysUserOnTenantVO>> findStaffUserByIdsForSpdm(@RequestBody List<Long> userIds) {
return R.ok(sysUserService.findStaffUserByIdsForSpdm(userIds));
}
/** /**
* 获取当前登录用户全部信息 * 获取当前登录用户全部信息
* *

View File

@@ -50,6 +50,8 @@ public interface SysUserService extends IService<SysUserEntity> {
List<SysUserOnTenantVO> findStaffUserByIds(List<Long> ids); List<SysUserOnTenantVO> findStaffUserByIds(List<Long> ids);
List<SysUserOnTenantVO> findStaffUserByIdsForSpdm(List<Long> ids);
List<SysUserVO> findAll(); List<SysUserVO> findAll();
SysUserVO findByUserId(Long userId); SysUserVO findByUserId(Long userId);

View File

@@ -452,6 +452,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity
return result; return result;
} }
@Override
public List<SysUserOnTenantVO> findStaffUserByIdsForSpdm(List<Long> ids) {
List<SysUserVO> dataList = this.findByIds(ids);
List<SysUserOnTenantVO> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(dataList)) {
for (SysUserVO sysUser : dataList) {
SysUserOnTenantVO sysStaffUser = new SysUserOnTenantVO();
BeanUtils.copyProperties(sysUser, sysStaffUser);
result.add(sysStaffUser);
}
}
return result;
}
@Override @Override
public List<SysUserVO> findAll() { public List<SysUserVO> findAll() {
List<SysUserEntity> userInfoList = this.list(new QueryWrapper<>()); List<SysUserEntity> userInfoList = this.list(new QueryWrapper<>());