From b47a7bf2508ad51b649fc056735b45f47d4a0d7c Mon Sep 17 00:00:00 2001 From: nixj Date: Fri, 12 Jul 2024 13:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90add=E3=80=91=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=96=B0=E5=A2=9E=E5=85=AC=E5=8F=B8=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chint/application/dtos/system/RolePageDto.java | 2 ++ .../com/chint/application/system/UserController.java | 2 +- .../com/chint/domain/service/UserDomainService.java | 10 +++++++++- .../mapper/JdbcUserDepartmentInfoBasicRepository.java | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/system/RolePageDto.java b/src/main/java/com/chint/application/dtos/system/RolePageDto.java index 6f95071f..313a3130 100644 --- a/src/main/java/com/chint/application/dtos/system/RolePageDto.java +++ b/src/main/java/com/chint/application/dtos/system/RolePageDto.java @@ -1,6 +1,7 @@ package com.chint.application.dtos.system; import com.chint.domain.aggregates.standards.StaffRank; +import com.chint.route.entity.UserDepartmentInfoBasic; import lombok.Data; import java.util.List; @@ -12,4 +13,5 @@ public class RolePageDto { private Long userId; List roleUserDtos; List staffRanks; + List departments; } diff --git a/src/main/java/com/chint/application/system/UserController.java b/src/main/java/com/chint/application/system/UserController.java index e56e1d43..e426e3a6 100644 --- a/src/main/java/com/chint/application/system/UserController.java +++ b/src/main/java/com/chint/application/system/UserController.java @@ -171,7 +171,7 @@ public class UserController { } - @ApiOperation("用户角色分页查询") + @ApiOperation("用户信息分页查询") @PostMapping("/role/pageQuery") public Result> rolePageQuery(@RequestBody RolePageQuery rolePageQuery) { return Result.Success(SUCCESS, userDomainService.userPageQuery(rolePageQuery)); diff --git a/src/main/java/com/chint/domain/service/UserDomainService.java b/src/main/java/com/chint/domain/service/UserDomainService.java index b68a90f2..d841917a 100644 --- a/src/main/java/com/chint/domain/service/UserDomainService.java +++ b/src/main/java/com/chint/domain/service/UserDomainService.java @@ -7,12 +7,13 @@ import com.chint.domain.aggregates.standards.StaffRank; import com.chint.domain.aggregates.user.Role; import com.chint.domain.aggregates.user.RoleUser; import com.chint.domain.aggregates.user.User; -import com.chint.domain.repository.RoleRepository; import com.chint.infrastructure.repository.jdbc.JdbcRoleRepository; import com.chint.infrastructure.repository.jdbc.JdbcRoleUserRepository; import com.chint.infrastructure.repository.jdbc.JdbcStaffRankRepository; import com.chint.infrastructure.repository.jdbc.JdbcUserRepository; import com.chint.infrastructure.util.PageResult; +import com.chint.route.entity.UserDepartmentInfoBasic; +import com.chint.route.mapper.JdbcUserDepartmentInfoBasicRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.stereotype.Component; @@ -32,6 +33,8 @@ public class UserDomainService { private JdbcRoleUserRepository jdbcRoleUserRepository; @Autowired private JdbcStaffRankRepository jdbcStaffRankRepository; + @Autowired + private JdbcUserDepartmentInfoBasicRepository jdbcUserDepartmentInfoBasicRepository; public PageResult userPageQuery(RolePageQuery rolePageQuery) { Page page=jdbcUserRepository.findAllByNameContainsAndEmployeeNoContains(rolePageQuery.getName(),rolePageQuery.getEmployeeNo(),rolePageQuery.getPageResult()); @@ -54,8 +57,12 @@ public class UserDomainService { } List roleIds=roleUsers.stream().map(RoleUser::getRoleId).toList(); List roles=jdbcRoleRepository.findAllByIdIn(roleIds); + //职级 List staffRanks=jdbcStaffRankRepository.findByEmployeeNoIn(users.stream().map(User::getEmployeeNo).toList()); Map> collect= staffRanks.stream().collect(Collectors.groupingBy(StaffRank::getEmployeeNo)); + //公司 + List departments=jdbcUserDepartmentInfoBasicRepository.findByUserIdIn(users.stream().map(User::getUserId).toList()); + Map> departmentCollect= departments.stream().collect(Collectors.groupingBy(UserDepartmentInfoBasic::getUserId)); List result = users.stream().map(temp -> { RolePageDto obj = new RolePageDto(); @@ -63,6 +70,7 @@ public class UserDomainService { obj.setEmployeeNo(temp.getEmployeeNo()); obj.setUserId(temp.getUserId()); obj.setStaffRanks(collect.get(temp.getEmployeeNo())); + obj.setDepartments(departmentCollect.get(temp.getUserId())); List roleUser = roleUsers.stream() .filter(s -> s.getUserId().equals(temp.getUserId())) .toList(); diff --git a/src/main/java/com/chint/route/mapper/JdbcUserDepartmentInfoBasicRepository.java b/src/main/java/com/chint/route/mapper/JdbcUserDepartmentInfoBasicRepository.java index f1690422..ced879c3 100644 --- a/src/main/java/com/chint/route/mapper/JdbcUserDepartmentInfoBasicRepository.java +++ b/src/main/java/com/chint/route/mapper/JdbcUserDepartmentInfoBasicRepository.java @@ -15,4 +15,6 @@ import java.util.List; public interface JdbcUserDepartmentInfoBasicRepository extends CrudRepository { List findByUserId(Long userId); + + List findByUserIdIn(List userIds); } \ No newline at end of file