From b02b9bc36e1ddc1c5f662898cecbb3371717217a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Mon, 19 Aug 2024 20:37:02 +0900 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20=EB=B6=80=EB=AA=A8=EC=A0=84?= =?UTF-8?q?=ED=99=94=EB=B2=88=ED=98=B8=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/data/req/JoinStudentReq.java | 3 ++- .../dodam/restapi/member/presentation/MemberController.java | 1 + .../java/b1nd/dodam/domain/rds/member/entity/Member.java | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) 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 aacff22b..1ce47841 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 @@ -9,7 +9,7 @@ import jakarta.validation.constraints.NotNull; public record JoinStudentReq(@NotEmpty String id, @NotEmpty String pw, @NotEmpty String name, @NotEmpty @Email String email, - @NotEmpty String phone, @NotNull int grade, @NotNull int room, @NotNull int number) { + @NotEmpty String phone, @NotNull String parentPhone, @NotNull int grade, @NotNull int room, @NotNull int number) { public Student mapToStudent(Member member) { return Student.builder() .member(member) @@ -27,6 +27,7 @@ public Member mapToMember(String encodedPw) { .name(name) .role(MemberRole.STUDENT) .phone(phone) + .parentPhone(parentPhone) .status(ActiveStatus.DEACTIVATE) .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 1d009775..afb50118 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 @@ -105,4 +105,5 @@ public ResponseData checkBroadcastClubMember(@PathVariable String id) { return queryUseCase.checkBroadcastClubMember(id); } + } 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 fe3569a0..98af8e64 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 @@ -44,8 +44,10 @@ public class Member extends BaseEntity { @NotNull private String phone; + private String parentPhone; + @Builder - public Member(String id, String pw, String name, String email, MemberRole role, ActiveStatus status, String profileImage, String phone) { + public Member(String id, String pw, String name, String email, MemberRole role, ActiveStatus status, String profileImage, String phone, String parentPhone) { this.id = id; this.pw = pw; this.email = email; @@ -54,6 +56,7 @@ public Member(String id, String pw, String name, String email, MemberRole role, this.status = status; this.profileImage = profileImage; this.phone = phone; + this.parentPhone = parentPhone; } public void updatePw(String pw) { From de83c95e013c33d5b4f5b5cece012b7b87cf7194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Tue, 20 Aug 2024 15:55:14 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20admin=EC=97=90=EC=84=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EC=88=98=EC=A0=95=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/MemberCommandUseCase.java | 29 +++++++++++++++++ .../data/req/UpdateStudentForAdminReq.java | 4 +++ .../member/presentation/MemberController.java | 9 ++++++ .../dodam-domain-rds/build.gradle | 2 ++ .../domain/rds/member/entity/Member.java | 31 ++++++++++++++----- .../domain/rds/member/entity/Student.java | 2 ++ .../domain/rds/member/entity/Teacher.java | 11 +++++++ .../member/exception/MemberExceptionCode.java | 3 +- .../member/exception/UnmodifiableRole.java | 12 +++++++ 9 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java create mode 100644 dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnmodifiableRole.java 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 b9c10539..dadc81e6 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 @@ -2,7 +2,9 @@ import b1nd.dodam.domain.rds.member.entity.Member; import b1nd.dodam.domain.rds.member.entity.Student; +import b1nd.dodam.domain.rds.member.entity.Teacher; import b1nd.dodam.domain.rds.member.enumeration.ActiveStatus; +import b1nd.dodam.domain.rds.member.enumeration.MemberRole; import b1nd.dodam.domain.rds.member.event.StudentRegisteredEvent; import b1nd.dodam.domain.rds.member.exception.*; import b1nd.dodam.domain.rds.member.service.MemberService; @@ -126,6 +128,33 @@ public Response updateStudentInfo(UpdateStudentInfoReq req) { return Response.noContent("내 학생 정보 수정 성공"); } + public Response updateInfoForAdmin(String id, MemberRole memberRole, UpdateStudentForAdminReq req){ + switch (memberRole) { + case STUDENT: + updateMemberInfo(id, req); + Student student = getStudentByMember(service.getMemberBy(id)); + student.updateInfo(req.grade(), req.room(), req.number()); + break; + + case TEACHER: + updateMemberInfo(id, req); + Teacher teacher = service.getTeacherBy(service.getMemberBy(id)); + teacher.updateInfoForAdmin(req.tel(), req.position()); + break; + + default: + throw new UnmodifiableRole(); + } + return Response.noContent("유저 정보 수정 성공"); + } + + private void updateMemberInfo(String id, UpdateStudentForAdminReq req) { + Member member = service.getMemberById(id) + .orElseThrow(MemberNotFoundException::new); + member.updateInfoForAdmin(req.name(), req.pw(), req.phone(), req.parentPhone()); + service.save(member); + } + private Student getStudentByMember(Member member) { return service.getStudentByMember(member) .orElseThrow(StudentNotFoundException::new); diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java new file mode 100644 index 00000000..31ed2b8c --- /dev/null +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java @@ -0,0 +1,4 @@ +package b1nd.dodam.restapi.member.application.data.req; + +public record UpdateStudentForAdminReq(String pw, String name, String phone, String parentPhone, Integer grade, + Integer room, Integer number, String tel, String position) {} 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 afb50118..0dbb6599 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 @@ -1,5 +1,6 @@ package b1nd.dodam.restapi.member.presentation; +import b1nd.dodam.domain.rds.member.enumeration.MemberRole; import b1nd.dodam.restapi.member.application.MemberCommandUseCase; import b1nd.dodam.restapi.member.application.MemberQueryUseCase; import b1nd.dodam.restapi.member.application.data.req.*; @@ -70,6 +71,14 @@ public Response updateStudentInfo(@RequestBody UpdateStudentInfoReq req) { return commandUseCase.updateStudentInfo(req); } + @PatchMapping("/info/{id}/{role}") + public Response updateInfoForAdmin(@PathVariable String id, + @PathVariable MemberRole role, + @RequestBody UpdateStudentForAdminReq req + ){ + return commandUseCase.updateInfoForAdmin(id, role, req); + } + @GetMapping("/{id}") public ResponseData getById(@PathVariable String id) { return queryUseCase.getById(id); diff --git a/dodam-system-domain/dodam-domain-rds/build.gradle b/dodam-system-domain/dodam-domain-rds/build.gradle index ab1f5ad8..6bd936f9 100644 --- a/dodam-system-domain/dodam-domain-rds/build.gradle +++ b/dodam-system-domain/dodam-domain-rds/build.gradle @@ -4,4 +4,6 @@ dependencies { implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.2' implementation 'jakarta.validation:jakarta.validation-api:3.0.2' + + implementation 'org.apache.commons:commons-lang3:3.13.0' } 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 98af8e64..cb007a28 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 @@ -4,14 +4,16 @@ import b1nd.dodam.domain.rds.member.enumeration.MemberRole; import b1nd.dodam.domain.rds.support.entity.BaseEntity; import com.fasterxml.jackson.annotation.JsonIgnore; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.Id; import jakarta.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; - -import java.util.Objects; +import org.apache.commons.lang3.StringUtils; @Getter @Entity(name = "member") @@ -64,20 +66,35 @@ public void updatePw(String pw) { } public void updateInfo(String name, String email, String phone, String profileImage) { - if(Objects.nonNull(name)) { + if(StringUtils.isNotBlank(name)){ this.name = name; } - if(Objects.nonNull(email)) { + if(StringUtils.isNotBlank(email)){ this.email = email; } - if(Objects.nonNull(phone)) { + if(StringUtils.isNotBlank(phone)){ this.phone = phone; } - if(Objects.nonNull(profileImage)) { + if(StringUtils.isNotBlank(profileImage)){ this.profileImage = profileImage; } } + public void updateInfoForAdmin(String pw, String name, String phone, String parentPhone){ + if(StringUtils.isNotBlank(pw)){ + this.phone = pw; + } + if(StringUtils.isNotBlank(name)){ + this.name = name; + } + if(StringUtils.isNotBlank(phone)){ + this.phone = phone; + } + if(StringUtils.isNotBlank(parentPhone)){ + this.parentPhone = parentPhone; + } + } + public void updateStatus(ActiveStatus status) { this.status = status; } diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java index dda1b71e..56bb1a7b 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java @@ -7,6 +7,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.Objects; + @Getter @Entity(name = "student") @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java index 67b312b6..8ddcd4a9 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java @@ -6,6 +6,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; @Getter @Entity(name = "teacher") @@ -33,4 +34,14 @@ public Teacher(Member member, String tel, String position) { this.position = position; } + public void updateInfoForAdmin(String tel, String position){ + if(StringUtils.isNotBlank(tel)){ + this.tel = tel; + } + if (StringUtils.isNotBlank(position)){ + this.position = position; + } + + } + } 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..e70357ae 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,7 +14,8 @@ public enum MemberExceptionCode implements ExceptionCode { PARENT_NOT_FOUND(404, "없는 부모님 정보"), TEACHER_NOT_FOUND(404, "없는 선생님"), MEMBER_DUPLICATION(409, "이미 존재하는 멤버"), - BROADCAST_CLUB_MEMBER_DUPLICATION(409, "이미 존재하는 방송부원"); + BROADCAST_CLUB_MEMBER_DUPLICATION(409, "이미 존재하는 방송부원"), + UNMODIFIABLE_ROLE(403, "해당 유저는 수정이 불가합니다"); 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/UnmodifiableRole.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnmodifiableRole.java new file mode 100644 index 00000000..727c9d1d --- /dev/null +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/exception/UnmodifiableRole.java @@ -0,0 +1,12 @@ +package b1nd.dodam.domain.rds.member.exception; + +import b1nd.dodam.core.exception.CustomException; + +public class UnmodifiableRole extends CustomException { + + public UnmodifiableRole() { + super(MemberExceptionCode.UNMODIFIABLE_ROLE); + } + +} + From 31ecb1c741d4a5de3bdceb182fa01b442ee9e390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Tue, 20 Aug 2024 16:10:58 +0900 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20=EC=97=94=ED=84=B0=20=EC=A7=80?= =?UTF-8?q?=EC=9B=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java index 8ddcd4a9..3ecf20d0 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java @@ -41,7 +41,6 @@ public void updateInfoForAdmin(String tel, String position){ if (StringUtils.isNotBlank(position)){ this.position = position; } - } } From 7ca22c4aa7f3252f6f819fa2dc5b3b3e1f23bb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Tue, 20 Aug 2024 21:47:18 +0900 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=EC=97=90=20=EB=A7=9E=EC=B6=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/MemberCommandUseCase.java | 37 ++++++++----------- .../application/data/req/JoinStudentReq.java | 2 +- .../data/req/UpdateStudentForAdminReq.java | 2 +- .../data/req/UpdateTeacherForAdminReq.java | 4 ++ .../member/presentation/MemberController.java | 16 ++++---- .../domain/rds/member/entity/Member.java | 10 +---- .../domain/rds/member/entity/Student.java | 14 +++++-- .../domain/rds/member/entity/Teacher.java | 3 +- 8 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateTeacherForAdminReq.java 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 dadc81e6..eeab90ac 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 @@ -4,7 +4,6 @@ import b1nd.dodam.domain.rds.member.entity.Student; import b1nd.dodam.domain.rds.member.entity.Teacher; import b1nd.dodam.domain.rds.member.enumeration.ActiveStatus; -import b1nd.dodam.domain.rds.member.enumeration.MemberRole; import b1nd.dodam.domain.rds.member.event.StudentRegisteredEvent; import b1nd.dodam.domain.rds.member.exception.*; import b1nd.dodam.domain.rds.member.service.MemberService; @@ -128,30 +127,26 @@ public Response updateStudentInfo(UpdateStudentInfoReq req) { return Response.noContent("내 학생 정보 수정 성공"); } - public Response updateInfoForAdmin(String id, MemberRole memberRole, UpdateStudentForAdminReq req){ - switch (memberRole) { - case STUDENT: - updateMemberInfo(id, req); - Student student = getStudentByMember(service.getMemberBy(id)); - student.updateInfo(req.grade(), req.room(), req.number()); - break; + public Response updateStudentForAdmin(String id, UpdateStudentForAdminReq req){ + updateMember(id, req.pw(), req.name(), req.phone()); - case TEACHER: - updateMemberInfo(id, req); - Teacher teacher = service.getTeacherBy(service.getMemberBy(id)); - teacher.updateInfoForAdmin(req.tel(), req.position()); - break; + Student student = getStudentByMember(service.getMemberBy(id)); + student.updateInfo(req.grade(), req.room(), req.number()); + student.setParentPhone(req.parentPhone()); + return Response.noContent("학생 정보 수정 성공"); + } - default: - throw new UnmodifiableRole(); - } - return Response.noContent("유저 정보 수정 성공"); + public Response updateTeacherForAdmin(String id, UpdateTeacherForAdminReq req){ + updateMember(id, req.pw(), req.name(), req.phone()); + + Teacher teacher = service.getTeacherBy(service.getMemberBy(id)); + teacher.updateInfo(req.tel(), req.position()); + return Response.noContent("선생 정보 수정 성공"); } - private void updateMemberInfo(String id, UpdateStudentForAdminReq req) { - Member member = service.getMemberById(id) - .orElseThrow(MemberNotFoundException::new); - member.updateInfoForAdmin(req.name(), req.pw(), req.phone(), req.parentPhone()); + private void updateMember(String id, String pw, String name, String phone) { + Member member = service.getMemberBy(id); + member.updateInfoForAdmin(pw, name, phone); service.save(member); } 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 1ce47841..9cc8449d 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 @@ -16,6 +16,7 @@ public Student mapToStudent(Member member) { .grade(grade) .room(room) .number(number) + .parentPhone(parentPhone) .build(); } @@ -27,7 +28,6 @@ public Member mapToMember(String encodedPw) { .name(name) .role(MemberRole.STUDENT) .phone(phone) - .parentPhone(parentPhone) .status(ActiveStatus.DEACTIVATE) .build(); } diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java index 31ed2b8c..2c74f9ad 100644 --- a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateStudentForAdminReq.java @@ -1,4 +1,4 @@ package b1nd.dodam.restapi.member.application.data.req; public record UpdateStudentForAdminReq(String pw, String name, String phone, String parentPhone, Integer grade, - Integer room, Integer number, String tel, String position) {} + Integer room, Integer number) {} diff --git a/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateTeacherForAdminReq.java b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateTeacherForAdminReq.java new file mode 100644 index 00000000..28b4f3ae --- /dev/null +++ b/dodam-application/dodam-rest-api/src/main/java/b1nd/dodam/restapi/member/application/data/req/UpdateTeacherForAdminReq.java @@ -0,0 +1,4 @@ +package b1nd.dodam.restapi.member.application.data.req; + +public record UpdateTeacherForAdminReq(String pw, String name, String phone, String tel, String position) { +} 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 0dbb6599..bf9e5370 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 @@ -1,6 +1,5 @@ package b1nd.dodam.restapi.member.presentation; -import b1nd.dodam.domain.rds.member.enumeration.MemberRole; import b1nd.dodam.restapi.member.application.MemberCommandUseCase; import b1nd.dodam.restapi.member.application.MemberQueryUseCase; import b1nd.dodam.restapi.member.application.data.req.*; @@ -71,12 +70,14 @@ public Response updateStudentInfo(@RequestBody UpdateStudentInfoReq req) { return commandUseCase.updateStudentInfo(req); } - @PatchMapping("/info/{id}/{role}") - public Response updateInfoForAdmin(@PathVariable String id, - @PathVariable MemberRole role, - @RequestBody UpdateStudentForAdminReq req - ){ - return commandUseCase.updateInfoForAdmin(id, role, req); + @PatchMapping("/student/info/{id}") + public Response updateStudentForAdmin(@PathVariable String id, @RequestBody UpdateStudentForAdminReq req){ + return commandUseCase.updateStudentForAdmin(id, req); + } + + @PatchMapping("/teacher/info/{id}") + public Response updateTeacherForAdmin(@PathVariable String id, @RequestBody UpdateTeacherForAdminReq req){ + return commandUseCase.updateTeacherForAdmin(id, req); } @GetMapping("/{id}") @@ -114,5 +115,4 @@ public ResponseData checkBroadcastClubMember(@PathVariable String id) { return queryUseCase.checkBroadcastClubMember(id); } - } 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 cb007a28..9736b043 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 @@ -46,10 +46,8 @@ public class Member extends BaseEntity { @NotNull private String phone; - private String parentPhone; - @Builder - public Member(String id, String pw, String name, String email, MemberRole role, ActiveStatus status, String profileImage, String phone, String parentPhone) { + public Member(String id, String pw, String name, String email, MemberRole role, ActiveStatus status, String profileImage, String phone) { this.id = id; this.pw = pw; this.email = email; @@ -58,7 +56,6 @@ public Member(String id, String pw, String name, String email, MemberRole role, this.status = status; this.profileImage = profileImage; this.phone = phone; - this.parentPhone = parentPhone; } public void updatePw(String pw) { @@ -80,7 +77,7 @@ public void updateInfo(String name, String email, String phone, String profileIm } } - public void updateInfoForAdmin(String pw, String name, String phone, String parentPhone){ + public void updateInfoForAdmin(String pw, String name, String phone){ if(StringUtils.isNotBlank(pw)){ this.phone = pw; } @@ -90,9 +87,6 @@ public void updateInfoForAdmin(String pw, String name, String phone, String pare if(StringUtils.isNotBlank(phone)){ this.phone = phone; } - if(StringUtils.isNotBlank(parentPhone)){ - this.parentPhone = parentPhone; - } } public void updateStatus(ActiveStatus status) { diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java index 56bb1a7b..60683ac5 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java @@ -6,8 +6,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; - -import java.util.Objects; +import org.apache.commons.lang3.StringUtils; @Getter @Entity(name = "student") @@ -31,12 +30,16 @@ public class Student { @NotNull private int number; + @NotNull + private String parentPhone; + @Builder - public Student(Member member, int grade, int room, int number) { + public Student(Member member, int grade, int room, int number, String parentPhone) { this.member = member; this.grade = grade; this.room = room; this.number = number; + this.parentPhone = parentPhone; } public void updateInfo(int grade, int room, int number) { @@ -45,4 +48,9 @@ public void updateInfo(int grade, int room, int number) { this.number = number; } + public void setParentPhone(String parentPhone) { + if(StringUtils.isNotBlank(parentPhone)){ + this.parentPhone = parentPhone; + } + } } diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java index 8ddcd4a9..bce50544 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Teacher.java @@ -34,14 +34,13 @@ public Teacher(Member member, String tel, String position) { this.position = position; } - public void updateInfoForAdmin(String tel, String position){ + public void updateInfo(String tel, String position){ if(StringUtils.isNotBlank(tel)){ this.tel = tel; } if (StringUtils.isNotBlank(position)){ this.position = position; } - } } From 74e09a6968cec1ef5e232b17f256de6c06d5fe7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=80=EC=98=81?= Date: Wed, 21 Aug 2024 10:29:58 +0900 Subject: [PATCH 5/5] =?UTF-8?q?chore:=20pw=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=98=A4=EB=A5=98=20=EB=B0=8F=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restapi/member/application/MemberCommandUseCase.java | 4 ++-- .../main/java/b1nd/dodam/domain/rds/member/entity/Member.java | 2 +- .../java/b1nd/dodam/domain/rds/member/entity/Student.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 eeab90ac..55b32985 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 @@ -132,7 +132,7 @@ public Response updateStudentForAdmin(String id, UpdateStudentForAdminReq req){ Student student = getStudentByMember(service.getMemberBy(id)); student.updateInfo(req.grade(), req.room(), req.number()); - student.setParentPhone(req.parentPhone()); + student.updateParentPhone(req.parentPhone()); return Response.noContent("학생 정보 수정 성공"); } @@ -146,7 +146,7 @@ public Response updateTeacherForAdmin(String id, UpdateTeacherForAdminReq req){ private void updateMember(String id, String pw, String name, String phone) { Member member = service.getMemberBy(id); - member.updateInfoForAdmin(pw, name, phone); + member.updateInfoForAdmin(encodePw(pw), name, phone); service.save(member); } 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 9736b043..9d3ad12b 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 @@ -79,7 +79,7 @@ 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.phone = pw; + this.pw = pw; } if(StringUtils.isNotBlank(name)){ this.name = name; diff --git a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java index 60683ac5..89987073 100644 --- a/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java +++ b/dodam-system-domain/dodam-domain-rds/src/main/java/b1nd/dodam/domain/rds/member/entity/Student.java @@ -48,7 +48,7 @@ public void updateInfo(int grade, int room, int number) { this.number = number; } - public void setParentPhone(String parentPhone) { + public void updateParentPhone(String parentPhone) { if(StringUtils.isNotBlank(parentPhone)){ this.parentPhone = parentPhone; }