-
Notifications
You must be signed in to change notification settings - Fork 0
RINGUS-62 feat: 북마크 멘토 목록 조회 기능 추가 #42
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
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
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
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
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
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
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 |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import com.querydsl.core.Tuple; | ||
| import com.querydsl.core.types.OrderSpecifier; | ||
| import com.querydsl.jpa.impl.JPAQuery; | ||
| import es.princip.ringus.domain.support.QueryDslSupport; | ||
| import es.princip.ringus.presentation.mentor.dto.CursorRequest; | ||
| import es.princip.ringus.presentation.mentor.dto.MentorCardResponse; | ||
|
|
@@ -13,6 +14,8 @@ | |
| import java.util.List; | ||
|
|
||
| import static com.querydsl.core.types.Order.ASC; | ||
| import static es.princip.ringus.domain.bookmark.QBookmark.bookmark; | ||
| import static es.princip.ringus.domain.mentee.QMentee.mentee; | ||
| import static es.princip.ringus.domain.mentor.QMentor.mentor; | ||
|
|
||
| @Repository | ||
|
|
@@ -21,28 +24,44 @@ public class MentorQueryDslRepositoryImpl extends QueryDslSupport implements Men | |
|
|
||
| private List<Tuple> fetchMentor( | ||
| final Pageable pageable, | ||
| final Long cursor | ||
| final Long cursor, | ||
| final Boolean bookmarked, | ||
| final Long memberId | ||
| ) { | ||
| return queryFactory.select( | ||
| mentor.id, | ||
| mentor.nickname, | ||
| mentor.profileImage, | ||
| mentor.introduction, | ||
| mentor.organization, | ||
| mentor.message | ||
| JPAQuery<Tuple> query = queryFactory.select( | ||
| mentor.id, | ||
| mentor.nickname, | ||
| mentor.profileImage, | ||
| mentor.introduction, | ||
| mentor.organization, | ||
| mentor.message | ||
| ) | ||
| .from(mentor) | ||
| .from(mentor); | ||
|
|
||
| if(bookmarked && memberId != null){ | ||
| query | ||
| .join(mentee).on(mentee.memberId.eq(memberId)) | ||
| .join(bookmark).on(mentor.id.eq(bookmark.mentor.id)) | ||
| .where( | ||
| bookmark.mentee.id.eq(mentee.id) | ||
| ); | ||
| } | ||
|
Comment on lines
+41
to
+48
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.
|
||
|
|
||
| query | ||
| .where(cursor != null ? mentor.id.goe( cursor) : mentor.id.isNotNull()) | ||
| .orderBy(new OrderSpecifier<>(ASC, mentor.id)) | ||
| .limit(pageable.getPageSize() + 1) | ||
| .fetch(); | ||
| .limit(pageable.getPageSize() + 1); | ||
|
|
||
| return query.fetch(); | ||
| } | ||
|
|
||
| private List<MentorCardResponse> fetchContent( | ||
| final Pageable pageable, | ||
| final Long cursor | ||
| final Long cursor, | ||
| final Boolean bookmared, | ||
| final Long memberId | ||
| ) { | ||
| return fetchMentor(pageable, cursor).stream() | ||
| return fetchMentor(pageable, cursor, bookmared, memberId).stream() | ||
| .map(tuple -> MentorCardResponse.of( | ||
| tuple.get(mentor.id), | ||
| tuple.get(mentor.nickname), | ||
|
|
@@ -56,8 +75,8 @@ private List<MentorCardResponse> fetchContent( | |
| } | ||
|
|
||
| @Override | ||
| public Slice<MentorCardResponse> findMentorBy(CursorRequest request, Pageable pageable) { | ||
| final List<MentorCardResponse> content = fetchContent(pageable, request.cursor()); | ||
| public Slice<MentorCardResponse> findMentorBy(CursorRequest request, Pageable pageable, Long memberId) { | ||
| final List<MentorCardResponse> content = fetchContent(pageable, request.cursor(), request.bookmarked(), memberId); | ||
| return paginate(pageable, content); | ||
| } | ||
| } | ||
5 changes: 4 additions & 1 deletion
5
src/main/java/es/princip/ringus/domain/mentor/MentorRepository.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
24 changes: 24 additions & 0 deletions
24
src/main/java/es/princip/ringus/global/aop/SessionToMemberId.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,24 @@ | ||
| package es.princip.ringus.global.aop; | ||
|
|
||
| import es.princip.ringus.domain.exception.MemberErrorCode; | ||
| import es.princip.ringus.global.exception.CustomRuntimeException; | ||
| import es.princip.ringus.global.util.CookieUtil; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import jakarta.servlet.http.HttpSession; | ||
|
|
||
| public class SessionToMemberId{ | ||
|
|
||
| public static Long getSessionMemberId (HttpServletRequest request, HttpServletResponse response){ | ||
| HttpSession session = request.getSession(false); | ||
|
|
||
| if(session == null || session.getAttribute("memberId") == null){ | ||
| throw new CustomRuntimeException(MemberErrorCode.SESSION_EXPIRED); | ||
| } | ||
|
|
||
| System.out.println("[Session Interceptor] : Interceptor 실행, 세션 유효, 멤버 ID: " + session.getAttribute("memberId")); | ||
| CookieUtil.addSessionCookie(response, session.getId()); | ||
| request.setAttribute("memberId", session.getAttribute("memberId")); | ||
| return (Long) request.getAttribute("memberId"); | ||
| } | ||
| } |
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
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
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
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.
Member인스턴스 메서드로isNotMentee가 구현 되어있습니다. 해당 메서드를 사용하면 재사용성이 높아질 것 같습니다!