From 773f2a9786f7038bfa0257a122e5d465ea0e7aef Mon Sep 17 00:00:00 2001 From: nixj Date: Thu, 11 Jul 2024 13:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90add=E3=80=91=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A7=92=E8=89=B2=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=E8=81=8C=E7=BA=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/application/dtos/system/RolePageDto.java | 2 ++ .../com/chint/domain/service/UserDomainService.java | 11 ++++++++++- .../repository/jdbc/JdbcStaffRankRepository.java | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) 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 86a600e8..6f95071f 100644 --- a/src/main/java/com/chint/application/dtos/system/RolePageDto.java +++ b/src/main/java/com/chint/application/dtos/system/RolePageDto.java @@ -1,5 +1,6 @@ package com.chint.application.dtos.system; +import com.chint.domain.aggregates.standards.StaffRank; import lombok.Data; import java.util.List; @@ -10,4 +11,5 @@ public class RolePageDto { private String employeeNo; private Long userId; List roleUserDtos; + List staffRanks; } diff --git a/src/main/java/com/chint/domain/service/UserDomainService.java b/src/main/java/com/chint/domain/service/UserDomainService.java index 4855453e..b68a90f2 100644 --- a/src/main/java/com/chint/domain/service/UserDomainService.java +++ b/src/main/java/com/chint/domain/service/UserDomainService.java @@ -3,12 +3,14 @@ package com.chint.domain.service; import com.chint.application.dtos.system.RolePageDto; import com.chint.application.dtos.system.RolePageQuery; import com.chint.application.dtos.system.RoleUserDto; +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 org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,8 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Component public class UserDomainService { @@ -24,9 +28,10 @@ public class UserDomainService { private JdbcUserRepository jdbcUserRepository; @Autowired private JdbcRoleRepository jdbcRoleRepository; - @Autowired private JdbcRoleUserRepository jdbcRoleUserRepository; + @Autowired + private JdbcStaffRankRepository jdbcStaffRankRepository; public PageResult userPageQuery(RolePageQuery rolePageQuery) { Page page=jdbcUserRepository.findAllByNameContainsAndEmployeeNoContains(rolePageQuery.getName(),rolePageQuery.getEmployeeNo(),rolePageQuery.getPageResult()); @@ -49,11 +54,15 @@ 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 result = users.stream().map(temp -> { RolePageDto obj = new RolePageDto(); obj.setName(temp.getName()); obj.setEmployeeNo(temp.getEmployeeNo()); obj.setUserId(temp.getUserId()); + obj.setStaffRanks(collect.get(temp.getEmployeeNo())); List roleUser = roleUsers.stream() .filter(s -> s.getUserId().equals(temp.getUserId())) .toList(); diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java index ae446d66..98e86f29 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcStaffRankRepository.java @@ -12,6 +12,7 @@ import java.util.List; public interface JdbcStaffRankRepository extends CrudRepository { List findByEmployeeNoAndTag(String employeeNo,String tag); List findByEmployeeNo(String employeeNo); + List findByEmployeeNoIn(List employeeNos); Page findAllByEmployeeNoContainsAndEmployeeNameContains(String employeeNo, String employeeName, Pageable pageable); }