관리자 목록 검색 수정
This commit is contained in:
@@ -29,10 +29,14 @@ class GetAdminsDao implements GetAdminsPortOut {
|
||||
public Page<GetAdmins> connect(Pageable pageable, GetAdminsCmd filterCommand) {
|
||||
// 관리자 목록 조회
|
||||
List<GetAdminsDto> admins = getAdminsMapper.findAll(filterCommand, pageable);
|
||||
|
||||
// 관리자의 역할 목록 조회
|
||||
List<GetAdminsRole> roles = getAdminsMapper.findRolesWithPrivilegesByAdminIds(
|
||||
admins.stream().map(GetAdminsDto::getSeq).toList());
|
||||
List<GetAdminsRole> roles;
|
||||
if(!admins.isEmpty()){
|
||||
roles = getAdminsMapper.findRolesWithPrivilegesByAdminIds(
|
||||
admins.stream().map(GetAdminsDto::getSeq).toList());
|
||||
} else {
|
||||
roles = null;
|
||||
}
|
||||
|
||||
|
||||
return new PageImpl<>(
|
||||
admins.stream()
|
||||
@@ -46,9 +50,9 @@ class GetAdminsDao implements GetAdminsPortOut {
|
||||
admin.getAccountDisabled(),
|
||||
admin.getAccountLocked(),
|
||||
admin.getTotal(),
|
||||
roles.stream()
|
||||
roles != null ? roles.stream()
|
||||
.filter(r -> r.getAdminSeq().equals(admin.getSeq()))
|
||||
.collect(Collectors.toList())
|
||||
.collect(Collectors.toList()):null
|
||||
)).toList(),
|
||||
pageable,
|
||||
admins.isEmpty() ? 0 : admins.get(0).getTotal());
|
||||
|
||||
@@ -9,6 +9,9 @@ import lombok.Setter;
|
||||
public class GetAdminsDto {
|
||||
private Long seq;
|
||||
private String id;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String regionMainCodeName;
|
||||
private String createdBy;
|
||||
private LocalDateTime createdAt;
|
||||
private String updatedBy;
|
||||
|
||||
@@ -10,4 +10,6 @@ public class GetAdminsCmd {
|
||||
private final String searchField;
|
||||
private final String searchValue;
|
||||
private final String searchRole;
|
||||
private final String searchArea;
|
||||
private final String searchDisabled;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
SELECT
|
||||
a.seq,
|
||||
a.id AS id,
|
||||
a.name,
|
||||
a.region_main_code,
|
||||
u.code_text as region_main_code_name,
|
||||
a.phone,
|
||||
a.created_by,
|
||||
a.created_at,
|
||||
a.updated_by,
|
||||
@@ -16,15 +20,24 @@
|
||||
a.account_locked,
|
||||
COUNT(*) OVER() AS total
|
||||
FROM admin a
|
||||
LEFT JOIN uicode u ON u.parent_id = 'code.region.main' AND u.id = a.region_main_code
|
||||
WHERE a.is_deleted = false
|
||||
|
||||
<if test="cmd.searchField != null and cmd.searchValue != null and cmd.searchValue != ''">
|
||||
<choose>
|
||||
<when test="cmd.searchField == 'email'">AND a.email ILIKE '%' || #{cmd.searchValue} || '%'</when>
|
||||
<when test="cmd.searchField == 'id'">AND a.id ILIKE '%' || #{cmd.searchValue} || '%'</when>
|
||||
<when test="cmd.searchField == 'name'">AND a.name LIKE '%' || #{cmd.searchValue} || '%'</when>
|
||||
<when test="cmd.searchField == 'id'">AND a.id LIKE '%' || #{cmd.searchValue} || '%'</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<if test="cmd.searchArea != null and cmd.searchArea != '' ">
|
||||
AND a.region_main_code = #{cmd.searchArea}
|
||||
</if>
|
||||
|
||||
<if test="cmd.searchDisabled != null and cmd.searchDisabled != '' ">
|
||||
AND a.account_disabled = #{cmd.searchDisabled}
|
||||
</if>
|
||||
|
||||
<if test="cmd.searchRole != null and cmd.searchRole != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
|
||||
Reference in New Issue
Block a user