-
Notifications
You must be signed in to change notification settings - Fork 0
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
마이 페이지 및 프로필 정보 수정 구현 #25
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3c408f3
feat : MyPage API 구현
YuSung011017 46fe9f0
feat: MyPage 응답 DTO 생성
YuSung011017 89250c6
feat: MyPage Repository 구현
YuSung011017 6b533a3
feat: MyPage Service 구현
YuSung011017 0f68bf4
Merge branch 'feat/#23' of https://github.com/TeamPu/TeamPu-Server in…
YuSung011017 691b372
fix : loginID 타입 변경
YuSung011017 be205dd
fix : MyPageDTO 반환형식 변경
YuSung011017 935091f
feat : 프로필 수정을 위한 updateProfile 구현
YuSung011017 ec1f376
프로필 수정을 위한 updateProfile API 구현
YuSung011017 ee973a6
프로필 수정에 필요한 UpdateProfileDTO 구현
YuSung011017 2439591
프로필 수정 로직 updateProfile 구현
YuSung011017 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 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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/kyonggi/teampu/domain/myPage/controller/MyPageController.java
This file contains 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,30 @@ | ||
package com.kyonggi.teampu.domain.myPage.controller; | ||
|
||
import com.kyonggi.teampu.domain.myPage.dto.MyPageRequest; | ||
import com.kyonggi.teampu.global.response.ApiResponse; | ||
import com.kyonggi.teampu.domain.myPage.dto.MyPageResponse; | ||
import com.kyonggi.teampu.domain.myPage.service.MyPageService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/profile") | ||
public class MyPageController { | ||
private final MyPageService myPageService; | ||
|
||
@GetMapping("/{login_id}") | ||
public ApiResponse<MyPageResponse.MyPageDTO> findByLoginId(@PathVariable("login_id") String loginId) { | ||
MyPageResponse.MyPageDTO memberDTO = myPageService.findByLoginId(loginId); | ||
return ApiResponse.ok(memberDTO); | ||
} | ||
|
||
@PatchMapping("/{login_id}") | ||
public ApiResponse<MyPageResponse.MyPageDTO> updateProfile( | ||
@PathVariable("login_id") String loginId, | ||
@RequestBody MyPageRequest.UpdateProfileDTO updateRequest) { | ||
MyPageResponse.MyPageDTO updatedMember = myPageService.updateProfile(loginId, updateRequest); | ||
return ApiResponse.ok(updatedMember); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/kyonggi/teampu/domain/myPage/dto/MyPageRequest.java
This file contains 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,14 @@ | ||
package com.kyonggi.teampu.domain.myPage.dto; | ||
|
||
import lombok.Getter; | ||
|
||
public class MyPageRequest { | ||
|
||
@Getter | ||
public static class UpdateProfileDTO { | ||
private String name; | ||
private String phoneNumber; | ||
private String email; | ||
} | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
src/main/java/com/kyonggi/teampu/domain/myPage/dto/MyPageResponse.java
This file contains 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,16 @@ | ||
package com.kyonggi.teampu.domain.myPage.dto; | ||
|
||
import lombok.*; | ||
|
||
public class MyPageResponse { | ||
|
||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
public static class MyPageDTO { | ||
private String loginId; | ||
private String name; | ||
private String phoneNumber; | ||
private String email; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/kyonggi/teampu/domain/myPage/repository/MemberRepository.java
This file contains 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,10 @@ | ||
package com.kyonggi.teampu.domain.myPage.repository; | ||
|
||
import com.kyonggi.teampu.domain.member.domain.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
Optional<Member> findByLoginId(String loginId); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/kyonggi/teampu/domain/myPage/service/MyPageService.java
This file contains 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,45 @@ | ||
package com.kyonggi.teampu.domain.myPage.service; | ||
|
||
import com.kyonggi.teampu.domain.member.domain.Member; | ||
import com.kyonggi.teampu.domain.myPage.dto.MyPageRequest; | ||
import com.kyonggi.teampu.domain.myPage.dto.MyPageResponse.MyPageDTO; | ||
import com.kyonggi.teampu.domain.myPage.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MyPageService { | ||
private final MemberRepository memberRepository; | ||
|
||
// 프로필 조회 | ||
@Transactional(readOnly = true) | ||
public MyPageDTO findByLoginId(String loginId) { | ||
Member member = memberRepository.findByLoginId(loginId) | ||
.orElseThrow(() -> new RuntimeException("사용자를 찾을 수 없습니다.")); | ||
|
||
return new MyPageDTO( | ||
member.getLoginId(), | ||
member.getName(), | ||
member.getPhoneNumber(), | ||
member.getEmail() | ||
); | ||
} | ||
|
||
@Transactional | ||
public MyPageDTO updateProfile(String loginId, MyPageRequest.UpdateProfileDTO updateRequest) { | ||
Member member = memberRepository.findByLoginId(loginId) | ||
.orElseThrow(() -> new RuntimeException("사용자를 찾을 수 없습니다.")); | ||
|
||
member.updateProfile(updateRequest.getName(), updateRequest.getPhoneNumber(), updateRequest.getEmail()); | ||
memberRepository.save(member); | ||
Comment on lines
+35
to
+36
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. setter 없이 처리한 부분 죠습니다...! 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. 호호 감샤합니다~ |
||
|
||
return new MyPageDTO( | ||
member.getLoginId(), | ||
member.getName(), | ||
member.getPhoneNumber(), | ||
member.getEmail() | ||
); | ||
} | ||
} |
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.
MyPageResponse에 필드를 바로 작성하지 않고 한 번 더 MyPageDTO로 감싸신 이유가 궁금합니다!
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.
재사용성이랑 보안? 관련되서 분리를 시켜서 진행하면 좋다고 해서 따라해봤습니다!