-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 멤버 관련 기능 추가 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e16de95
b2bdf51
7b3f77b
5e4578b
8be1292
4398120
86dce3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package knu_chatbot.application.dto.request; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class ChangePasswordServiceRequest { | ||
|
|
||
| private String oldPassword; | ||
| private String newPassword; | ||
| private String confirmNewPassword; | ||
|
|
||
| @Builder | ||
| public ChangePasswordServiceRequest(String oldPassword, String newPassword, String confirmNewPassword) { | ||
| this.oldPassword = oldPassword; | ||
| this.newPassword = newPassword; | ||
| this.confirmNewPassword = confirmNewPassword; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package knu_chatbot.application.dto.response; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.ToString; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @ToString | ||
| public class ChangePasswordResponse { | ||
|
|
||
| private String message; | ||
|
|
||
| @Builder | ||
| public ChangePasswordResponse(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public static ChangePasswordResponse of(String message) { | ||
| return ChangePasswordResponse.builder() | ||
| .message(message) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package knu_chatbot.application.dto.response; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| public class LogoutResponse { | ||
|
|
||
| private String message; | ||
|
|
||
| @Builder | ||
| public LogoutResponse(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public static LogoutResponse of(String message) { | ||
| return LogoutResponse.builder() | ||
| .message(message) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package knu_chatbot.application.dto.response; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| public class WithdrawResponse { | ||
|
|
||
| private String message; | ||
|
|
||
| @Builder | ||
| public WithdrawResponse(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public static WithdrawResponse of(String message) { | ||
| return WithdrawResponse.builder() | ||
| .message(message) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ public enum ErrorCode { | |
| E1006, | ||
| E1007, | ||
| E1008, | ||
| E1009, | ||
| E1010, | ||
|
|
||
| // 히스토리 | ||
| E2000, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,8 +35,7 @@ public void save(Member member) { | |
|
|
||
| @Override | ||
| public MemberDto findByEmail(String email) { | ||
| Member member = memberJpaRepository.findByEmail(email) | ||
| .orElseThrow(() -> new KnuChatbotException(ErrorType.USER_INVALID_ERROR)); | ||
| Member member = getOrThrowMemberByEmail(email); | ||
| return memberMapper.convert(member); | ||
| } | ||
|
|
||
|
|
@@ -56,4 +55,23 @@ public void deleteRefreshToken(String refreshToken) { | |
| redisTemplate.delete(refreshToken); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteMemberByEmail(String email) { | ||
| memberJpaRepository.deleteByEmail(email); | ||
| } | ||
|
|
||
| @Override | ||
| public void updatePasswordByEmail(String email, String newEncryptedPassword) { | ||
| Member member = getOrThrowMemberByEmail(email); | ||
|
|
||
| member.changePassword(newEncryptedPassword); | ||
|
|
||
| memberJpaRepository.save(member); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| private Member getOrThrowMemberByEmail(String email) { | ||
| return memberJpaRepository.findByEmail(email) | ||
| .orElseThrow(() -> new KnuChatbotException(ErrorType.USER_INVALID_ERROR)); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package knu_chatbot.presentation.request; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import knu_chatbot.application.dto.request.ChangePasswordServiceRequest; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.hibernate.validator.constraints.Length; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| public class ChangePasswordRequest { | ||
|
|
||
| @NotBlank(message = "이전 비밀번호는 필수입니다.") | ||
| private String oldPassword; | ||
|
|
||
| @NotBlank(message = "새로운 비밀번호는 필수입니다.") | ||
| @Length(min = 8, max = 20, message = "길이는 최소 8글자, 최대 20글자 입니다.") | ||
| private String newPassword; | ||
|
|
||
| @NotBlank(message = "새로운 비밀번호 확인은 필수입니다.") | ||
| private String confirmNewPassword; | ||
|
|
||
| @Builder | ||
| public ChangePasswordRequest(String oldPassword, String newPassword, String confirmNewPassword) { | ||
| this.oldPassword = oldPassword; | ||
| this.newPassword = newPassword; | ||
| this.confirmNewPassword = confirmNewPassword; | ||
| } | ||
|
|
||
| public ChangePasswordServiceRequest toServiceRequest() { | ||
| return ChangePasswordServiceRequest.builder() | ||
| .oldPassword(oldPassword) | ||
| .newPassword(newPassword) | ||
| .confirmNewPassword(confirmNewPassword) | ||
| .build(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
회원 탈퇴 시
member만 삭제하고 관련 데이터(히스토리, 채팅)는 삭제하지 않고 있습니다.TODO로 명시되어 있지만, 이로 인해 고아 데이터(orphaned data)가 발생하여 데이터 무결성을 해칠 수 있습니다. 회원과 연관된 모든 데이터를 함께 삭제하거나, soft delete를 적용하는 것을 고려해야 합니다. 예를 들어,Member엔티티에deleted플래그를 추가하고 회원 탈퇴 시 이 플래그를 업데이트하는 방식이 있습니다.