From 3772aebd256da44d9a3323c5defff9301680f5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Thu, 22 Aug 2024 17:27:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=EC=B4=88=EA=B8=B0=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=EC=8B=9C=20pending=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EA=B0=80=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restapi/member/application/MemberQueryUseCase.java | 6 ++++++ .../restapi/member/application/data/req/JoinStudentReq.java | 2 +- .../restapi/member/application/data/req/JoinTeacherReq.java | 2 +- .../dodam/restapi/member/presentation/MemberController.java | 5 +++++ .../dodam/domain/rds/member/enumeration/ActiveStatus.java | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java index 11f87be9..86ae6af0 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java @@ -42,6 +42,12 @@ public ResponseData> getDeactivateMembers() { .toList()); } + public ResponseData> getPendingMembers() { + return ResponseData.ok("가입 대기 멤버 조회 성공", service.getByStatus(ActiveStatus.PENDING).parallelStream() + .map(this::getMemberInfo) + .toList()); + } + public ResponseData> getAll() { return ResponseData.ok("모든 멤버 정보 조회 성공", service.getByStatus(ActiveStatus.ACTIVE).parallelStream() .map(this::getMemberInfo) diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinStudentReq.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinStudentReq.java index 9cc8449d..9308ee6c 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinStudentReq.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinStudentReq.java @@ -28,7 +28,7 @@ public Member mapToMember(String encodedPw) { .name(name) .role(MemberRole.STUDENT) .phone(phone) - .status(ActiveStatus.DEACTIVATE) + .status(ActiveStatus.PENDING) .build(); } } diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinTeacherReq.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinTeacherReq.java index caccb438..9ef8edb3 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinTeacherReq.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/JoinTeacherReq.java @@ -25,7 +25,7 @@ public Member mapToMember(String encodedPw) { .name(name) .role(MemberRole.TEACHER) .phone(phone) - .status(ActiveStatus.DEACTIVATE) + .status(ActiveStatus.PENDING) .build(); } } diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java index bf9e5370..0823c851 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java @@ -100,6 +100,11 @@ public ResponseData> getDeactivateMembers() { return queryUseCase.getDeactivateMembers(); } + @GetMapping("/pending") + public ResponseData> getPendingMembers() { + return queryUseCase.getPendingMembers(); + } + @GetMapping("/all") public ResponseData> getAll() { return queryUseCase.getAll(); diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java index d2461c7a..8469b0f6 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java @@ -2,6 +2,6 @@ public enum ActiveStatus { - ACTIVE, DEACTIVATE + ACTIVE, DEACTIVATE, PENDING } From 83947df432351cc43f7f54e9deb88d345dbb8701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Wed, 4 Sep 2024 12:41:09 +0900 Subject: [PATCH 2/5] =?UTF-8?q?chore:=20controller=EC=97=90=EC=84=9C(id)?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dodam/restapi/member/presentation/MemberController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java index 6f9137eb..b9dfb9de 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java @@ -42,7 +42,7 @@ public Response delete(@PathVariable String id) { } @PatchMapping("/status/{id}") - public Response updateStatus(@PathVariable("id") String id, @RequestParam ActiveStatus status){ + public Response updateStatus(@PathVariable String id, @RequestParam ActiveStatus status){ return commandUseCase.status(id, status); } From ee82417ef444a6292f042e489c4cdf57f7298c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Wed, 4 Sep 2024 13:47:09 +0900 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20status=EB=B3=84=EB=A1=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restapi/member/application/MemberQueryUseCase.java | 9 ++++++++- .../restapi/member/presentation/MemberController.java | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java index 5626acce..28f486bf 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberQueryUseCase.java @@ -44,6 +44,13 @@ public ResponseData> searchByName(String name) { .toList()); } + public ResponseData> getMembersByStatus(ActiveStatus status) { + return ResponseData.ok("상태변 멤버 조회 성공", memberRepository.findByStatusOrderByStudent(status) + .parallelStream() + .map(this::getMemberInfo) + .toList()); + } + public ResponseData> getDeactivateMembers() { return ResponseData.ok("비활성화된 멤버 조회 성공", memberRepository.findByStatusOrderByStudent(ActiveStatus.DEACTIVATE) .parallelStream() @@ -52,7 +59,7 @@ public ResponseData> getDeactivateMembers() { } public ResponseData> getPendingMembers(){ - return ResponseData.ok("보류중인 멤버 조회 성공", memberRepository.findByStatusOrderByStudent(ActiveStatus.PENDING) + return ResponseData.ok("대기중인 멤버 조회 성공", memberRepository.findByStatusOrderByStudent(ActiveStatus.PENDING) .parallelStream() .map(this::getMemberInfo) .toList()); diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java index b9dfb9de..97034801 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/presentation/MemberController.java @@ -101,6 +101,11 @@ public ResponseData> searchByName(@RequestParam String name) return queryUseCase.searchByName(name); } + @GetMapping("/status") + public ResponseData> getMembersByStatus(@RequestParam ActiveStatus status) { + return queryUseCase.getMembersByStatus(status); + } + @GetMapping("/deactivate") public ResponseData> getDeactivateMembers() { return queryUseCase.getDeactivateMembers(); From 56497ad1bfc9fbdfbaf842ef328cdb5cc383ac80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Wed, 4 Sep 2024 13:49:39 +0900 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20Exception=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rds/member/exception/MemberExceptionCode.java | 3 +-- .../rds/member/exception/UnauthorizedException.java | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnauthorizedException.java diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java index f0163b1f..8931dc23 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java @@ -14,8 +14,7 @@ public enum MemberExceptionCode implements ExceptionCode { PARENT_NOT_FOUND(404, "없는 부모님 정보"), TEACHER_NOT_FOUND(404, "없는 선생님"), MEMBER_DUPLICATION(409, "이미 존재하는 멤버"), - BROADCAST_CLUB_MEMBER_DUPLICATION(409, "이미 존재하는 방송부원"), - UNAUTHORIZED(403, "권한 없음"); + BROADCAST_CLUB_MEMBER_DUPLICATION(409, "이미 존재하는 방송부원"); private final int status; private final String message; diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnauthorizedException.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnauthorizedException.java deleted file mode 100644 index 38eeecab..00000000 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnauthorizedException.java +++ /dev/null @@ -1,12 +0,0 @@ -package b1nd.dodam.domain.rds.member.exception; - -import b1nd.dodam.core.exception.CustomException; - -public final class UnauthorizedException extends CustomException { - - public UnauthorizedException() { - super(MemberExceptionCode.UNAUTHORIZED); - } - -} - From 9bc6dc5ac68baff5346cd426918ca38f5a966a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Wed, 4 Sep 2024 14:48:23 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refac:=20status=20DEACTIVATE=20->=20DEACTIV?= =?UTF-8?q?ATED=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20&&=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=EC=8B=9C=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20?= =?UTF-8?q?=EA=B2=80=EC=82=AC=20if=EB=AC=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restapi/auth/application/AuthUseCase.java | 2 +- .../application/MemberCommandUseCase.java | 2 +- .../domain/rds/member/entity/Member.java | 22 ++++--------------- .../rds/member/enumeration/ActiveStatus.java | 2 +- .../exception/DeactivateMemberException.java | 11 ---------- .../member/exception/MemberExceptionCode.java | 2 +- .../exception/MemberNotActiveException.java | 10 +++++++++ 7 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/DeactivateMemberException.java create mode 100644 dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberNotActiveException.java diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/auth/application/AuthUseCase.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/auth/application/AuthUseCase.java index e20fde65..517c9d8a 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/auth/application/AuthUseCase.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/auth/application/AuthUseCase.java @@ -34,7 +34,7 @@ public AuthUseCase(MemberRepository memberRepository, public CompletableFuture> login(LoginReq req) { Member member = memberRepository.getById(req.id()); member.checkIfPasswordIsCorrect(Sha512PasswordEncoder.encode(req.pw())); - member.checkIfStatusIsDeactivate(); + member.checkIfStatusIncorrect(); return CompletableFuture.supplyAsync(() -> member, executor) .thenCompose(m -> tokenClient.issueTokens(member.getId(), member.getRole().getNumber())) .thenApply(tokens -> new LoginRes(member, tokens.accessToken(), tokens.refreshToken())) diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberCommandUseCase.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberCommandUseCase.java index 575bf310..509aa960 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberCommandUseCase.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/MemberCommandUseCase.java @@ -105,7 +105,7 @@ public Response deactivate(String id) { @CacheEvict(value = "members-cache", key = "'activeMembers'") public Response deactivate() { Member member = memberAuthenticationHolder.current(); - member.updateStatus(ActiveStatus.DEACTIVATE); + member.updateStatus(ActiveStatus.DEACTIVATED); memberRepository.save(member); return Response.ok("멤버 비활성화 성공"); } diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Member.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Member.java index 4cf654d8..b5038e46 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Member.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Member.java @@ -2,9 +2,7 @@ import b1nd.dodam.domain.rds.member.enumeration.ActiveStatus; import b1nd.dodam.domain.rds.member.enumeration.MemberRole; -import b1nd.dodam.domain.rds.member.exception.ActiveMemberException; -import b1nd.dodam.domain.rds.member.exception.DeactivateMemberException; -import b1nd.dodam.domain.rds.member.exception.WrongPasswordException; +import b1nd.dodam.domain.rds.member.exception.*; import b1nd.dodam.domain.rds.support.entity.BaseEntity; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; @@ -80,18 +78,6 @@ public void updateInfo(String name, String email, String phone, String profileIm } } - public void updateInfoForAdmin(String pw, String name, String phone){ - if(StringUtils.isNotBlank(pw)){ - this.pw = pw; - } - if(StringUtils.isNotBlank(name)){ - this.name = name; - } - if(StringUtils.isNotBlank(phone)){ - this.phone = phone; - } - } - public void updateStatus(ActiveStatus status) { this.status = status; } @@ -108,9 +94,9 @@ public void checkIfStatusIsActive() { } } - public void checkIfStatusIsDeactivate() { - if(this.status == ActiveStatus.DEACTIVATE) { - throw new DeactivateMemberException(); + public void checkIfStatusIncorrect() { + if(!(this.status == ActiveStatus.ACTIVE)) { + throw new MemberNotActiveException(); } } diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java index 8469b0f6..e3296293 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/enumeration/ActiveStatus.java @@ -2,6 +2,6 @@ public enum ActiveStatus { - ACTIVE, DEACTIVATE, PENDING + ACTIVE, DEACTIVATE, PENDING, DEACTIVATED } diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/DeactivateMemberException.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/DeactivateMemberException.java deleted file mode 100644 index 5be94681..00000000 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/DeactivateMemberException.java +++ /dev/null @@ -1,11 +0,0 @@ -package b1nd.dodam.domain.rds.member.exception; - -import b1nd.dodam.core.exception.CustomException; - -public final class DeactivateMemberException extends CustomException { - - public DeactivateMemberException() { - super(MemberExceptionCode.DEACTIVATE_MEMBER); - } - -} diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java index 8931dc23..99714081 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberExceptionCode.java @@ -7,7 +7,7 @@ public enum MemberExceptionCode implements ExceptionCode { WRONG_PASSWORD(401, "잘못된 비밀번호"), - DEACTIVATE_MEMBER(403, "비활성화된 멤버"), + MEMBER_NOT_ACTIVE(403, "활성화되지 않은 멤버"), ACTIVE_MEMBER(403, "활성화된 멤버"), MEMBER_NOT_FOUND(404, "없는 멤버"), STUDENT_NOT_FOUND(404, "없는 학생"), diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberNotActiveException.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberNotActiveException.java new file mode 100644 index 00000000..7333f024 --- /dev/null +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/MemberNotActiveException.java @@ -0,0 +1,10 @@ +package b1nd.dodam.domain.rds.member.exception; + +import b1nd.dodam.core.exception.CustomException; + +public class MemberNotActiveException extends CustomException { + + public MemberNotActiveException() { + super(MemberExceptionCode.MEMBER_NOT_ACTIVE); + } +} \ No newline at end of file