-
Notifications
You must be signed in to change notification settings - Fork 0
π Profile Modify #38
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 34 additions & 3 deletions
37
src/main/java/com/mycom/socket/go_socket/controller/ProfileController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,51 @@ | ||
| package com.mycom.socket.go_socket.controller; | ||
|
|
||
| import com.mycom.socket.auth.security.MemberDetails; | ||
| import com.mycom.socket.go_socket.dto.request.PasswordUpdateRequest; | ||
| import com.mycom.socket.go_socket.dto.request.ProfileUpdateRequest; | ||
| import com.mycom.socket.go_socket.dto.response.ProfileResponse; | ||
| import com.mycom.socket.go_socket.entity.Member; | ||
| import com.mycom.socket.go_socket.service.MemberService; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/profile") | ||
| public class ProfileController { | ||
|
|
||
| private final MemberService memberService; | ||
|
|
||
| @GetMapping | ||
| public ProfileResponse getProfile(@AuthenticationPrincipal MemberDetails memberDetails) { | ||
| return ProfileResponse.of(memberDetails.getMember()); | ||
| } | ||
|
|
||
| @PutMapping | ||
| public ProfileResponse updateProfile( | ||
| @AuthenticationPrincipal MemberDetails memberDetails, | ||
| @RequestBody @Valid ProfileUpdateRequest request | ||
| ) { | ||
| Member updatedMember = memberService.updateProfile( | ||
| memberDetails.getMember().getEmail(), | ||
| request.nickname(), | ||
| request.intro() | ||
| ); | ||
| return ProfileResponse.of(updatedMember); | ||
| } | ||
|
|
||
| @PutMapping("/password") | ||
| public void updatePassword( | ||
| @AuthenticationPrincipal MemberDetails memberDetails, | ||
| @RequestBody @Valid PasswordUpdateRequest request | ||
| ) { | ||
| memberService.updatePassword( | ||
| memberDetails.getMember().getEmail(), | ||
| request.currentPassword(), | ||
| request.newPassword() | ||
| ); | ||
| } | ||
|
|
||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/mycom/socket/go_socket/dto/request/PasswordUpdateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.mycom.socket.go_socket.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record PasswordUpdateRequest( | ||
| @NotBlank(message = "νμ¬ λΉλ°λ²νΈλ νμμ λλ€") | ||
| String currentPassword, | ||
| @NotBlank(message = "μ λΉλ°λ²νΈλ νμμ λλ€") | ||
| @Size(min = 8, message = "λΉλ°λ²νΈλ 8μ μ΄μμ΄μ΄μΌ ν©λλ€") | ||
| String newPassword | ||
| ) {} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/mycom/socket/go_socket/dto/request/ProfileUpdateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.mycom.socket.go_socket.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record ProfileUpdateRequest( | ||
| @NotBlank(message = "λλ€μμ νμμ λλ€") | ||
| @Size(min = 2, max = 20, message = "λλ€μμ 2μ μ΄μ 20μ μ΄νμ¬μΌ ν©λλ€") | ||
| String nickname, | ||
| @Size(max = 100, message = "μκΈ°μκ°λ 100μλ₯Ό μ΄κ³Όν μ μμ΅λλ€") | ||
| String intro | ||
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,4 +50,13 @@ public Member(String email, String nickname, String password, String intro, Memb | |
| public void updateRefreshToken(String updateRefreshToken) { | ||
| this.refreshToken = updateRefreshToken; | ||
| } | ||
|
|
||
| public void updateProfile(String nickname, String intro) { | ||
| this.nickname = nickname; | ||
| this.intro = intro; | ||
| } | ||
|
Comment on lines
+54
to
+57
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. π οΈ Refactor suggestion νλ‘ν μ΄λ―Έμ§ URL μ λ°μ΄νΈ λ©μλ λλ½ νλ‘ν μ΄λ―Έμ§ URL νλκ° μ‘΄μ¬νμ§λ§ μ λ°μ΄νΈ λ©μλκ° λλ½λμμ΅λλ€. public void updateProfile(String nickname, String intro) {
this.nickname = nickname;
this.intro = intro;
}
+
+ public void updateProfileImage(String profileImgUrl) {
+ this.profileImgUrl = profileImgUrl;
+ }
|
||
|
|
||
| public void updatePassword(String encodedPassword) { | ||
| this.password = encodedPassword; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
보μ μ€μ λ³κ²½ νμ: νλ‘ν μλν¬μΈνΈ μΈμ¦ νμ
νλ‘ν κ΄λ ¨ μλν¬μΈνΈ(
/api/profile/**)λ₯Ό μΈμ¦ μμ΄ μ κ·Ό κ°λ₯νλλ‘ μ€μ ν κ²μ 보μμ μνν©λλ€. νλ‘ν μμ μ μΈμ¦λ μ¬μ©μλ§ κ°λ₯ν΄μΌ ν©λλ€.λ€μκ³Ό κ°μ΄ μμ μ μ μν©λλ€:
μΆκ°λ‘ νΉμ νλ‘ν μλν¬μΈνΈμ λν μΈλΆνλ κΆν μ€μ μ΄ νμν©λλ€: