【add】用户角色分页查询接口新增职级数据
This commit is contained in:
parent
dfb90dfa31
commit
773f2a9786
|
@ -1,5 +1,6 @@
|
||||||
package com.chint.application.dtos.system;
|
package com.chint.application.dtos.system;
|
||||||
|
|
||||||
|
import com.chint.domain.aggregates.standards.StaffRank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,4 +11,5 @@ public class RolePageDto {
|
||||||
private String employeeNo;
|
private String employeeNo;
|
||||||
private Long userId;
|
private Long userId;
|
||||||
List<RoleUserDto> roleUserDtos;
|
List<RoleUserDto> roleUserDtos;
|
||||||
|
List<StaffRank> staffRanks;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,14 @@ package com.chint.domain.service;
|
||||||
import com.chint.application.dtos.system.RolePageDto;
|
import com.chint.application.dtos.system.RolePageDto;
|
||||||
import com.chint.application.dtos.system.RolePageQuery;
|
import com.chint.application.dtos.system.RolePageQuery;
|
||||||
import com.chint.application.dtos.system.RoleUserDto;
|
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.Role;
|
||||||
import com.chint.domain.aggregates.user.RoleUser;
|
import com.chint.domain.aggregates.user.RoleUser;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.repository.RoleRepository;
|
import com.chint.domain.repository.RoleRepository;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcRoleRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcRoleRepository;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcRoleUserRepository;
|
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.repository.jdbc.JdbcUserRepository;
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,6 +19,8 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class UserDomainService {
|
public class UserDomainService {
|
||||||
|
@ -24,9 +28,10 @@ public class UserDomainService {
|
||||||
private JdbcUserRepository jdbcUserRepository;
|
private JdbcUserRepository jdbcUserRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcRoleRepository jdbcRoleRepository;
|
private JdbcRoleRepository jdbcRoleRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcRoleUserRepository jdbcRoleUserRepository;
|
private JdbcRoleUserRepository jdbcRoleUserRepository;
|
||||||
|
@Autowired
|
||||||
|
private JdbcStaffRankRepository jdbcStaffRankRepository;
|
||||||
|
|
||||||
public PageResult<RolePageDto> userPageQuery(RolePageQuery rolePageQuery) {
|
public PageResult<RolePageDto> userPageQuery(RolePageQuery rolePageQuery) {
|
||||||
Page<User> page=jdbcUserRepository.findAllByNameContainsAndEmployeeNoContains(rolePageQuery.getName(),rolePageQuery.getEmployeeNo(),rolePageQuery.getPageResult());
|
Page<User> page=jdbcUserRepository.findAllByNameContainsAndEmployeeNoContains(rolePageQuery.getName(),rolePageQuery.getEmployeeNo(),rolePageQuery.getPageResult());
|
||||||
|
@ -49,11 +54,15 @@ public class UserDomainService {
|
||||||
}
|
}
|
||||||
List<Long> roleIds=roleUsers.stream().map(RoleUser::getRoleId).toList();
|
List<Long> roleIds=roleUsers.stream().map(RoleUser::getRoleId).toList();
|
||||||
List<Role> roles=jdbcRoleRepository.findAllByIdIn(roleIds);
|
List<Role> roles=jdbcRoleRepository.findAllByIdIn(roleIds);
|
||||||
|
List<StaffRank> staffRanks=jdbcStaffRankRepository.findByEmployeeNoIn(users.stream().map(User::getEmployeeNo).toList());
|
||||||
|
Map<String, List<StaffRank>> collect= staffRanks.stream().collect(Collectors.groupingBy(StaffRank::getEmployeeNo));
|
||||||
|
|
||||||
List<RolePageDto> result = users.stream().map(temp -> {
|
List<RolePageDto> result = users.stream().map(temp -> {
|
||||||
RolePageDto obj = new RolePageDto();
|
RolePageDto obj = new RolePageDto();
|
||||||
obj.setName(temp.getName());
|
obj.setName(temp.getName());
|
||||||
obj.setEmployeeNo(temp.getEmployeeNo());
|
obj.setEmployeeNo(temp.getEmployeeNo());
|
||||||
obj.setUserId(temp.getUserId());
|
obj.setUserId(temp.getUserId());
|
||||||
|
obj.setStaffRanks(collect.get(temp.getEmployeeNo()));
|
||||||
List<RoleUser> roleUser = roleUsers.stream()
|
List<RoleUser> roleUser = roleUsers.stream()
|
||||||
.filter(s -> s.getUserId().equals(temp.getUserId()))
|
.filter(s -> s.getUserId().equals(temp.getUserId()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
public interface JdbcStaffRankRepository extends CrudRepository<StaffRank, Integer> {
|
public interface JdbcStaffRankRepository extends CrudRepository<StaffRank, Integer> {
|
||||||
List<StaffRank> findByEmployeeNoAndTag(String employeeNo,String tag);
|
List<StaffRank> findByEmployeeNoAndTag(String employeeNo,String tag);
|
||||||
List<StaffRank> findByEmployeeNo(String employeeNo);
|
List<StaffRank> findByEmployeeNo(String employeeNo);
|
||||||
|
List<StaffRank> findByEmployeeNoIn(List<String> employeeNos);
|
||||||
|
|
||||||
Page<StaffRank> findAllByEmployeeNoContainsAndEmployeeNameContains(String employeeNo, String employeeName, Pageable pageable);
|
Page<StaffRank> findAllByEmployeeNoContainsAndEmployeeNameContains(String employeeNo, String employeeName, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue