-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Feat: 동호회 목록 조회 시 유저 관심 종목 기반 우선 정렬 적용 #76
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
base: develop
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -129,19 +129,26 @@ public ClubDetailResponse getClub(Long clubId) { | |
| } | ||
| @Override | ||
| @Transactional(readOnly = true) | ||
| public ClubScrollResponse getClubsByScroll(Long cursor, int size) { | ||
| public ClubScrollResponse getClubsByScroll(Long cursor, int size, Long userId) { | ||
|
|
||
| // +1 조회해서 다음 페이지 존재 여부 판단 | ||
| Pageable pageable = PageRequest.of(0, size + 1); | ||
|
|
||
| List<Club> clubs = clubRepository.findClubsByCursor(cursor, pageable); | ||
| List<Club> clubs = new java.util.ArrayList<>(clubRepository.findClubsByCursor(cursor, pageable)); | ||
|
|
||
| boolean hasNext = clubs.size() > size; | ||
|
|
||
| if (hasNext) { | ||
| clubs = clubs.subList(0, size); | ||
| } | ||
|
|
||
| // 유저 관심 종목 조회 후 일치하는 동호회 상단 정렬 | ||
| List<com.be.sportizebe.common.enums.SportType> interestTypes = userRepository.findById(userId) | ||
| .map(user -> user.getInterestType()) | ||
| .orElse(java.util.Collections.emptyList()); | ||
|
|
||
| clubs.sort(java.util.Comparator.comparingInt(club -> | ||
| interestTypes.contains(club.getClubType()) ? 0 : 1)); | ||
|
Comment on lines
134
to
+150
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. 현재 로직은 “관심 종목 우선 정렬”을 전체 목록 기준으로 보장하지 못합니다.
🤖 Prompt for AI Agents |
||
|
|
||
| List<ClubListItemResponse> items = clubs.stream() | ||
| .map(club -> { | ||
| int memberCount = clubMemberRepository.countByClubId(club.getId()); | ||
|
|
||
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.
공개 조회 엔드포인트에서 바로 NPE 가 날 수 있습니다.
GET /api/**는src/main/java/com/be/sportizebe/global/security/SecurityConfig.java:36-44에서permitAll()이고,src/main/java/com/be/sportizebe/global/jwt/JwtAuthenticationFilter.java:32-72도 토큰이 없으면 principal 을 채우지 않습니다. 그래서 여기의userAuthInfo는 null 일 수 있는데, 바로getId()를 호출해서 비인증 조회가 500 으로 끝납니다. 이 엔드포인트를 인증 필수로 바꾸거나, principal 이 없으면 비개인화 정렬로 내려가도록 controller/service 를 함께 null-safe 하게 처리해야 합니다.🤖 Prompt for AI Agents