From 59e4409411e38c32183aec4ecfcf2fb9adb39819 Mon Sep 17 00:00:00 2001 From: Lee jiwoo <102974424+20210805jiwoo@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:13:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=EC=8A=B9=EC=9D=B8=20=EB=8C=80?= =?UTF-8?q?=EA=B8=B0/=EC=99=84=EB=A3=8C=20=EC=9A=B4=EC=98=81=EC=A7=84=20dt?= =?UTF-8?q?o=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sponseDto.java => ManagerResponseDto.java} | 10 ++++---- .../UnauthorizedManagerResponseDto.java | 25 ------------------- 2 files changed, 5 insertions(+), 30 deletions(-) rename src/main/java/com/tave/tavewebsite/domain/member/dto/response/{AuthorizedManagerResponseDto.java => ManagerResponseDto.java} (80%) delete mode 100644 src/main/java/com/tave/tavewebsite/domain/member/dto/response/UnauthorizedManagerResponseDto.java diff --git a/src/main/java/com/tave/tavewebsite/domain/member/dto/response/AuthorizedManagerResponseDto.java b/src/main/java/com/tave/tavewebsite/domain/member/dto/response/ManagerResponseDto.java similarity index 80% rename from src/main/java/com/tave/tavewebsite/domain/member/dto/response/AuthorizedManagerResponseDto.java rename to src/main/java/com/tave/tavewebsite/domain/member/dto/response/ManagerResponseDto.java index f932e84..6143808 100644 --- a/src/main/java/com/tave/tavewebsite/domain/member/dto/response/AuthorizedManagerResponseDto.java +++ b/src/main/java/com/tave/tavewebsite/domain/member/dto/response/ManagerResponseDto.java @@ -4,22 +4,22 @@ import com.tave.tavewebsite.domain.member.entity.JobType; import com.tave.tavewebsite.domain.member.entity.Member; -public record AuthorizedManagerResponseDto( +public record ManagerResponseDto( Long id, String username, - String nickname, DepartmentType department, JobType job, + String nickname, String generation, String agitId ) { - public static AuthorizedManagerResponseDto fromEntity(Member member) { - return new AuthorizedManagerResponseDto( + public static ManagerResponseDto fromEntity(Member member) { + return new ManagerResponseDto( member.getId(), member.getUsername(), - member.getNickname(), member.getDepartment(), member.getJob(), + member.getNickname(), member.getGeneration(), member.getAgitId() ); diff --git a/src/main/java/com/tave/tavewebsite/domain/member/dto/response/UnauthorizedManagerResponseDto.java b/src/main/java/com/tave/tavewebsite/domain/member/dto/response/UnauthorizedManagerResponseDto.java deleted file mode 100644 index 14217c4..0000000 --- a/src/main/java/com/tave/tavewebsite/domain/member/dto/response/UnauthorizedManagerResponseDto.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.tave.tavewebsite.domain.member.dto.response; - -import com.tave.tavewebsite.domain.member.entity.DepartmentType; -import com.tave.tavewebsite.domain.member.entity.JobType; -import com.tave.tavewebsite.domain.member.entity.Member; - -public record UnauthorizedManagerResponseDto( - - String username, - DepartmentType department, - JobType job, - String generation, - String agitId - -) { - public static UnauthorizedManagerResponseDto fromEntity(Member member){ - return new UnauthorizedManagerResponseDto( - member.getUsername(), - member.getDepartment(), - member.getJob(), - member.getGeneration(), - member.getAgitId() - ); - } -} From 671a3cb1e5b35397b8ee6e304eac233b05802501 Mon Sep 17 00:00:00 2001 From: Lee jiwoo <102974424+20210805jiwoo@users.noreply.github.com> Date: Sat, 7 Dec 2024 00:34:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EC=97=90=EB=9F=AC=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/exception/ErrorMessage.java | 3 ++- .../exception/InvalidStatusValueExcception.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/tave/tavewebsite/domain/member/exception/InvalidStatusValueExcception.java diff --git a/src/main/java/com/tave/tavewebsite/domain/member/exception/ErrorMessage.java b/src/main/java/com/tave/tavewebsite/domain/member/exception/ErrorMessage.java index 85e2008..eda85e5 100644 --- a/src/main/java/com/tave/tavewebsite/domain/member/exception/ErrorMessage.java +++ b/src/main/java/com/tave/tavewebsite/domain/member/exception/ErrorMessage.java @@ -13,7 +13,8 @@ public enum ErrorMessage { _NOT_MATCHED_VERIFIED_NUMBER(400, "인증 번호가 일치하지 않습니다."), _EXPIRED_NUMBER(401, "인증번호의 만료시간이 지났습니다."), _NOT_MATCHED_PASSWORD(400, "비밀번호가 일치하지 않습니다."), - NOT_MANAGER(400, "MANAGER이 아닙니다."); + NOT_MANAGER(400, "MANAGER이 아닙니다."), + INVALID_STATUS_VALUE(400, "유효하지 않은 상태 값입니다."); final int code; final String message; diff --git a/src/main/java/com/tave/tavewebsite/domain/member/exception/InvalidStatusValueExcception.java b/src/main/java/com/tave/tavewebsite/domain/member/exception/InvalidStatusValueExcception.java new file mode 100644 index 0000000..f343312 --- /dev/null +++ b/src/main/java/com/tave/tavewebsite/domain/member/exception/InvalidStatusValueExcception.java @@ -0,0 +1,11 @@ +package com.tave.tavewebsite.domain.member.exception; + +import com.tave.tavewebsite.global.exception.BaseErrorException; + +import static com.tave.tavewebsite.domain.member.exception.ErrorMessage.INVALID_STATUS_VALUE; + +public class InvalidStatusValueExcception extends BaseErrorException { + public InvalidStatusValueExcception() { + super(INVALID_STATUS_VALUE.getCode(), INVALID_STATUS_VALUE.getMessage()); + } +} From 1055ce3374a6e439e0f35943cb215be4057b1cbb Mon Sep 17 00:00:00 2001 From: Lee jiwoo <102974424+20210805jiwoo@users.noreply.github.com> Date: Sat, 7 Dec 2024 00:35:10 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tavewebsite/domain/member/controller/SuccessMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tave/tavewebsite/domain/member/controller/SuccessMessage.java b/src/main/java/com/tave/tavewebsite/domain/member/controller/SuccessMessage.java index 9e12c91..608c874 100644 --- a/src/main/java/com/tave/tavewebsite/domain/member/controller/SuccessMessage.java +++ b/src/main/java/com/tave/tavewebsite/domain/member/controller/SuccessMessage.java @@ -6,7 +6,8 @@ public enum SuccessMessage { UNAUTHORIZED_MEMBER_READ("승인 대기 중인 운영진을 조회했습니다."), AUTHORIZED_MEMBER_READ("승인된 운영진을 조회했습니다."), - MANAGER_DELETE("해당 운영진을 삭제했습니다."); + MANAGER_DELETE("해당 운영진을 삭제했습니다."), + ALL_MANAGER_READ("모든 운영진을 조회했습니다."); private final String message; From 64570b5e11966281c75a6896f58d23aa045eee04 Mon Sep 17 00:00:00 2001 From: Lee jiwoo <102974424+20210805jiwoo@users.noreply.github.com> Date: Sat, 7 Dec 2024 00:36:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=EC=8A=B9=EC=9D=B8=20=EB=8C=80?= =?UTF-8?q?=EA=B8=B0/=EC=99=84=EB=A3=8C=20=EC=9A=B4=EC=98=81=EC=A7=84=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=EB=AC=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/AdminController.java | 22 ++++----- .../memberRepository/MemberRepository.java | 4 +- .../domain/member/service/AdminService.java | 45 ++++++++++++------- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/tave/tavewebsite/domain/member/controller/AdminController.java b/src/main/java/com/tave/tavewebsite/domain/member/controller/AdminController.java index 2b60380..3570fd0 100644 --- a/src/main/java/com/tave/tavewebsite/domain/member/controller/AdminController.java +++ b/src/main/java/com/tave/tavewebsite/domain/member/controller/AdminController.java @@ -1,11 +1,12 @@ package com.tave.tavewebsite.domain.member.controller; -import com.tave.tavewebsite.domain.member.dto.response.AuthorizedManagerResponseDto; -import com.tave.tavewebsite.domain.member.dto.response.UnauthorizedManagerResponseDto; +import com.tave.tavewebsite.domain.member.dto.response.ManagerResponseDto; import com.tave.tavewebsite.domain.member.service.AdminService; import com.tave.tavewebsite.global.success.SuccessResponse; -import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PageableDefault; import org.springframework.web.bind.annotation.*; @RestController @@ -15,16 +16,11 @@ public class AdminController { private final AdminService adminService; - @GetMapping("/unauthorized") - public SuccessResponse> getUnauthorizedManager() { - List response = adminService.getUnauthorizedManager(); - return new SuccessResponse<>(response, SuccessMessage.UNAUTHORIZED_MEMBER_READ.getMessage()); - } - - @GetMapping("/authorized") - public SuccessResponse> getAuthorizedAdmins() { - List response = adminService.getAuthorizedAdmins(); - return new SuccessResponse<>(response, SuccessMessage.AUTHORIZED_MEMBER_READ.getMessage()); + @GetMapping("/manager") + public SuccessResponse> getManagers( + @RequestParam(defaultValue = "ALL", name = "status") String status, + @PageableDefault(size = 8) Pageable pageable) { + return adminService.getManagersByStatus(status, pageable); } @DeleteMapping("/{memberId}") diff --git a/src/main/java/com/tave/tavewebsite/domain/member/memberRepository/MemberRepository.java b/src/main/java/com/tave/tavewebsite/domain/member/memberRepository/MemberRepository.java index 31c90b3..5d7d3ae 100644 --- a/src/main/java/com/tave/tavewebsite/domain/member/memberRepository/MemberRepository.java +++ b/src/main/java/com/tave/tavewebsite/domain/member/memberRepository/MemberRepository.java @@ -2,6 +2,8 @@ import com.tave.tavewebsite.domain.member.entity.Member; import com.tave.tavewebsite.domain.member.entity.RoleType; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; @@ -13,5 +15,5 @@ public interface MemberRepository extends JpaRepository { Optional findByNickname(String Nickname); - List findByRole(RoleType role); + Page findByRole(RoleType role, Pageable pageable); } diff --git a/src/main/java/com/tave/tavewebsite/domain/member/service/AdminService.java b/src/main/java/com/tave/tavewebsite/domain/member/service/AdminService.java index 64afa1b..f574e9b 100644 --- a/src/main/java/com/tave/tavewebsite/domain/member/service/AdminService.java +++ b/src/main/java/com/tave/tavewebsite/domain/member/service/AdminService.java @@ -1,17 +1,17 @@ package com.tave.tavewebsite.domain.member.service; -import static com.tave.tavewebsite.domain.member.entity.RoleType.MANAGER; -import static com.tave.tavewebsite.domain.member.entity.RoleType.UNAUTHORIZED_MANAGER; - -import com.tave.tavewebsite.domain.member.dto.response.AuthorizedManagerResponseDto; -import com.tave.tavewebsite.domain.member.dto.response.UnauthorizedManagerResponseDto; +import com.tave.tavewebsite.domain.member.controller.SuccessMessage; +import com.tave.tavewebsite.domain.member.dto.response.ManagerResponseDto; import com.tave.tavewebsite.domain.member.entity.Member; import com.tave.tavewebsite.domain.member.entity.RoleType; +import com.tave.tavewebsite.domain.member.exception.InvalidStatusValueExcception; import com.tave.tavewebsite.domain.member.exception.NotFoundMemberException; import com.tave.tavewebsite.domain.member.exception.NotManagerAccessException; import com.tave.tavewebsite.domain.member.memberRepository.MemberRepository; -import java.util.List; +import com.tave.tavewebsite.global.success.SuccessResponse; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,18 +28,29 @@ public void updateAuthentication(String memberId) { member.updateRole(); } - @Transactional(readOnly = true) - public List getAuthorizedAdmins() { - return memberRepository.findByRole(MANAGER).stream() - .map(AuthorizedManagerResponseDto::fromEntity) - .toList(); - } + public SuccessResponse> getManagersByStatus(String status, Pageable pageable) { + Page members; + String message; + + switch (status.toUpperCase()) { + case "ALL": + members = memberRepository.findAll(pageable); + message = SuccessMessage.ALL_MANAGER_READ.getMessage(); + break; + case "AUTHORIZED": + members = memberRepository.findByRole(RoleType.MANAGER, pageable); + message = SuccessMessage.AUTHORIZED_MEMBER_READ.getMessage(); + break; + case "UNAUTHORIZED": + members = memberRepository.findByRole(RoleType.UNAUTHORIZED_MANAGER, pageable); + message = SuccessMessage.UNAUTHORIZED_MEMBER_READ.getMessage(); + break; + default: + throw new InvalidStatusValueExcception(); + } - @Transactional(readOnly = true) - public List getUnauthorizedManager() { - return memberRepository.findByRole(UNAUTHORIZED_MANAGER).stream() - .map(UnauthorizedManagerResponseDto::fromEntity) - .toList(); + Page response = members.map(ManagerResponseDto::fromEntity); + return new SuccessResponse<>(response, message); } public Member findMemberById(Long memberId) {