-
Notifications
You must be signed in to change notification settings - Fork 2
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
#112 마이페이지 조회 API 구현 #113
Merged
Merged
#112 마이페이지 조회 API 구현 #113
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/example/aboutme/app/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,35 @@ | ||
package com.example.aboutme.app.controller; | ||
|
||
import com.example.aboutme.apiPayload.ApiResponse; | ||
import com.example.aboutme.app.dto.MyPageResponse; | ||
import com.example.aboutme.service.MemberService.MemberService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/mypages") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class MyPageController { | ||
|
||
private final MemberService memberService; | ||
|
||
/** | ||
* [GET] /mypages | ||
* @param memberId 멤버 식별자 | ||
* @return | ||
*/ | ||
@GetMapping("") | ||
public ApiResponse<MyPageResponse.GetMyPageDTO> getMyPage(@RequestHeader("member-id") Long memberId){ | ||
|
||
MyPageResponse.GetMyPageDTO getMyPageDTO = memberService.getMyPage(memberId); | ||
|
||
log.info("마이페이지 조회: {}", memberId); | ||
|
||
return ApiResponse.onSuccess(getMyPageDTO); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/example/aboutme/app/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,46 @@ | ||
package com.example.aboutme.app.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class MyPageResponse { | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class GetMyPageDTO { | ||
@JsonProperty("my_info") | ||
private MyPageInfo myPageInfo; | ||
|
||
@JsonProperty("insight") | ||
private MyPageInsight myPageInsight; | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class MyPageInfo{ | ||
@JsonProperty("profile_name") | ||
private String profileName; | ||
|
||
@JsonProperty("space_name") | ||
private String spaceName; | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class MyPageInsight{ | ||
@JsonProperty("profile_shared_num") | ||
private int profileSharedNum; | ||
|
||
@JsonProperty("space_shared_num") | ||
private int spaceSharedNum; | ||
} | ||
} |
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
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
2 changes: 2 additions & 0 deletions
2
src/main/java/com/example/aboutme/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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/example/aboutme/repository/ProfileFeatureRepository.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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
package com.example.aboutme.repository; | ||
|
||
import com.example.aboutme.domain.Member; | ||
import com.example.aboutme.domain.ProfileFeature; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface ProfileFeatureRepository extends JpaRepository<ProfileFeature, Long> { | ||
List<ProfileFeature> findByProfileKeyAndProfileValueContaining(String profileKey, String profileValue); | ||
|
||
@Query("select pf.profileValue " + | ||
"from Profile p " + | ||
"join ProfileFeature pf on p = pf.profile " + | ||
"where pf.profileKey = 'name' and p.member = :member " + | ||
"order by p.isDefault desc, p.createdAt asc ") | ||
List<String> findProfileFeature(@Param("member") Member member, Pageable pageable); | ||
} |
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
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
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
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.
Paging하신 이유가 궁금합니다.
@query("select pf.profileValue " +
"from Profile p " +
"join ProfileFeature pf on p = pf.profile " +
"where pf.profileKey = 'name' and p.member = :member " +
"order by p.isDefault desc, p.createdAt asc ")
List findProfileFeature(@param("member") Member member);
...
String profileName = profileFeatureRepository.findProfileFeature(member).get(0);
이렇게 페이지네이션 처리없이 조회했을 때와 비교하여 이점이 있는 건가요?
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.
저도 paging으로 처리하고싶진 않았는데,
profile feature가 여러개 나올 수 있는 상황에서 jpql로는 sql의 limit 키워드가 안먹어서
어쩔 수 없이 paging으로 처리했습니다ㅠ 혹시 더 좋은 방법이 있다면 알려주시면 감사하겠습니다!
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.
넵 확인했습니다. 저도 궁금해서 질문드린거라 더 좋은 방법은 모르겠네요😅