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); }