-
Notifications
You must be signed in to change notification settings - Fork 0
[hotfix] 방 검색 api 수정 #231
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
[hotfix] 방 검색 api 수정 #231
Changes from all commits
028c8c4
a5cbf03
a230c2c
1dcc9e7
37e0028
b71d9b6
be5a5b7
d437c42
b76eca0
48c8518
6ce03aa
e5d8272
4276ff8
ad4419d
f3cb1bd
d9d9073
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 |
|---|---|---|
|
|
@@ -6,8 +6,8 @@ | |
| import konkuk.thip.common.util.CursorBasedList; | ||
| import konkuk.thip.room.adapter.in.web.response.RoomGetHomeJoinedListResponse; | ||
| import konkuk.thip.room.adapter.in.web.response.RoomRecruitingDetailViewResponse; | ||
| import konkuk.thip.room.adapter.in.web.response.RoomSearchResponse; | ||
| import konkuk.thip.room.adapter.out.persistence.function.RoomQueryFunction; | ||
| import konkuk.thip.room.adapter.out.persistence.function.IntegerCursorRoomQueryFunction; | ||
| import konkuk.thip.room.adapter.out.persistence.function.LocalDateCursorRoomQueryFunction; | ||
| import konkuk.thip.room.adapter.out.persistence.repository.RoomJpaRepository; | ||
| import konkuk.thip.room.adapter.out.persistence.repository.category.CategoryJpaRepository; | ||
| import konkuk.thip.room.application.port.out.RoomQueryPort; | ||
|
|
@@ -35,8 +35,36 @@ public int countRecruitingRoomsByBookAndStartDateAfter(String isbn, LocalDate cu | |
| } | ||
|
|
||
| @Override | ||
| public Page<RoomSearchResponse.RoomSearchResult> searchRoom(String keyword, String category, Pageable pageable) { | ||
| return roomJpaRepository.searchRoom(keyword, category, pageable); | ||
| public CursorBasedList<RoomQueryDto> searchRecruitingRoomsByDeadline(String keyword, Cursor cursor) { | ||
| return findRoomsByDeadlineCursor(cursor, ((lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findRecruitingRoomsOrderByStartDateAsc(keyword, lastLocalDate, lastId, pageSize))); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> searchRecruitingRoomsWithCategoryByDeadline(String keyword, Category category, Cursor cursor) { | ||
| return findRoomsByDeadlineCursor(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findRecruitingRoomsWithCategoryOrderByStartDateAsc( | ||
| keyword, category.getValue(), lastLocalDate, lastId, pageSize | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> searchRecruitingRoomsByMemberCount(String keyword, Cursor cursor) { | ||
| return findRoomsByMemberCountCursor(cursor, (lastMemberCount, lastId, pageSize) -> | ||
| roomJpaRepository.findRecruitingRoomsOrderByMemberCountDesc( | ||
| keyword, lastMemberCount, lastId, pageSize | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> searchRecruitingRoomsWithCategoryByMemberCount(String keyword, Category category, Cursor cursor) { | ||
| return findRoomsByMemberCountCursor(cursor, (lastMemberCount, lastId, pageSize) -> | ||
| roomJpaRepository.findRecruitingRoomsWithCategoryOrderByMemberCountDesc( | ||
| keyword, category.getValue(), lastMemberCount, lastId, pageSize | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -46,51 +74,67 @@ public List<RoomRecruitingDetailViewResponse.RecommendRoom> findOtherRecruitingR | |
| } | ||
|
|
||
| @Override | ||
| public Page<RoomGetHomeJoinedListResponse.RoomSearchResult> searchHomeJoinedRooms(Long userId, LocalDate date, Pageable pageable) { | ||
| public Page<RoomGetHomeJoinedListResponse.JoinedRoomInfo> searchHomeJoinedRooms(Long userId, LocalDate date, Pageable pageable) { | ||
| return roomJpaRepository.searchHomeJoinedRooms(userId, date, pageable); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> findRecruitingRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| return findRoomsByDeadlineCursor(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findRecruitingRoomsUserParticipated(userId, lastLocalDate, lastId, pageSize)); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> findPlayingRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| return findRoomsByDeadlineCursor(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findPlayingRoomsUserParticipated(userId, lastLocalDate, lastId, pageSize)); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> findPlayingAndRecruitingRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| return findRoomsByDeadlineCursor(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findPlayingAndRecruitingRoomsUserParticipated(userId, lastLocalDate, lastId, pageSize)); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> findExpiredRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| return findRoomsByDeadlineCursor(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findExpiredRoomsUserParticipated(userId, lastLocalDate, lastId, pageSize)); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomQueryDto> findRoomsByIsbnOrderByDeadline(String isbn, Cursor cursor) { | ||
| return findRooms(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| return findRoomsByDeadlineCursor(cursor, (lastLocalDate, lastId, pageSize) -> | ||
| roomJpaRepository.findRoomsByIsbnOrderByStartDateAsc(isbn, lastLocalDate, lastId, pageSize)); | ||
| } | ||
|
|
||
| private CursorBasedList<RoomQueryDto> findRooms(Cursor cursor, RoomQueryFunction queryFunction) { | ||
| private CursorBasedList<RoomQueryDto> findRoomsByDeadlineCursor(Cursor cursor, LocalDateCursorRoomQueryFunction queryFunction) { | ||
| LocalDate lastLocalDate = cursor.isFirstRequest() ? null : cursor.getLocalDate(0); | ||
| Long lastId = cursor.isFirstRequest() ? null : cursor.getLong(1); | ||
| int pageSize = cursor.getPageSize(); | ||
|
|
||
| List<RoomQueryDto> dtos = queryFunction.apply(lastLocalDate, lastId, pageSize); | ||
|
|
||
| return CursorBasedList.of(dtos, pageSize, roomShowMineQueryDto -> { | ||
| return CursorBasedList.of(dtos, pageSize, dto -> { | ||
| Cursor nextCursor = new Cursor(List.of( | ||
| dto.endDate().toString(), | ||
| dto.roomId().toString() | ||
| )); | ||
| return nextCursor.toEncodedString(); | ||
| }); | ||
| } | ||
|
Comment on lines
+111
to
+125
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. 커서 구성 시 startDate/“endDate” 필드 혼용 가능성 — 불일치로 인한 버그 위험 키셋 정렬은 startDate ASC + roomId ASC 기준인데, nextCursor는 dto.endDate()를 사용하고 있습니다. 현재 RoomQueryRepositoryImpl에서는 projection으로 room.startDate를 선택합니다. DTO 접근자가 endDate라는 이름으로 startDate를 담고 있다면 동작은 하지만, 네이밍 불일치가 유지보수 시 심각한 혼동/버그를 유발할 수 있습니다. 정렬 기준과 동일하게 startDate 접근자를 사용하도록 정리하는 것을 권장합니다. 다음과 같이 수정하는 것을 제안합니다(실제 접근자 명은 DTO 정의에 맞춰 조정 필요): - dto.endDate().toString(),
+ dto.startDate().toString(),또한 RoomQueryDto/QRoomQueryDto의 필드/생성자 명세에서 startDate/endDate 명칭을 정합성 있게 통일해주세요. 🤖 Prompt for AI Agents
Collaborator
Author
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. 이건 나도 동감해 그래서 dto 변수 네이밍을 수정할 예정이야
이렇게 수정할 예정이야 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. @seongjunnoh 네, 정말 좋은 개선 계획이네요! 더 의미가 명확한 네이밍으로 변경하시면 코드 가독성과 유지보수성이 크게 향상될 것 같습니다:
이렇게 하면 커서 생성 시에도 🐰 🧠 Learnings used |
||
|
|
||
| private CursorBasedList<RoomQueryDto> findRoomsByMemberCountCursor(Cursor cursor, IntegerCursorRoomQueryFunction queryFunction) { | ||
| Integer lastInteger = cursor.isFirstRequest() ? null : cursor.getInteger(0); | ||
| Long lastId = cursor.isFirstRequest() ? null : cursor.getLong(1); | ||
| int pageSize = cursor.getPageSize(); | ||
|
|
||
| List<RoomQueryDto> dtos = queryFunction.apply(lastInteger, lastId, pageSize); | ||
|
|
||
| return CursorBasedList.of(dtos, pageSize, dto -> { | ||
| Cursor nextCursor = new Cursor(List.of( | ||
| roomShowMineQueryDto.endDate().toString(), | ||
| roomShowMineQueryDto.roomId().toString() | ||
| String.valueOf(dto.memberCount()), // 인원수 커서 | ||
| dto.roomId().toString() | ||
| )); | ||
| return nextCursor.toEncodedString(); | ||
|
Comment on lines
+111
to
139
Contributor
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. 오호 함수형 인터페이스로 추출하셨네요 굿입니다! |
||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package konkuk.thip.room.adapter.out.persistence.function; | ||
|
|
||
| import konkuk.thip.room.application.port.out.dto.RoomQueryDto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @FunctionalInterface | ||
| public interface IntegerCursorRoomQueryFunction { | ||
| List<RoomQueryDto> apply(Integer lastInteger, Long lastId, int pageSize); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
|
|
||
| import konkuk.thip.room.adapter.in.web.response.RoomRecruitingDetailViewResponse; | ||
| import konkuk.thip.room.adapter.in.web.response.RoomGetHomeJoinedListResponse; | ||
| import konkuk.thip.room.adapter.in.web.response.RoomSearchResponse; | ||
| import konkuk.thip.room.application.port.out.dto.RoomQueryDto; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
|
|
@@ -13,11 +12,17 @@ | |
|
|
||
| public interface RoomQueryRepository { | ||
|
|
||
| Page<RoomSearchResponse.RoomSearchResult> searchRoom(String keyword, String category, Pageable pageable); | ||
| /** | ||
| * 방 검색 | ||
| */ | ||
| List<RoomQueryDto> findRecruitingRoomsOrderByStartDateAsc(String keyword, LocalDate lastStartDate, Long roomId, int pageSize); | ||
| List<RoomQueryDto> findRecruitingRoomsWithCategoryOrderByStartDateAsc(String keyword, String categoryVal, LocalDate lastStartDate, Long roomId, int pageSize); | ||
| List<RoomQueryDto> findRecruitingRoomsOrderByMemberCountDesc(String keyword, Integer lastMemberCount, Long roomId, int pageSize); | ||
| List<RoomQueryDto> findRecruitingRoomsWithCategoryOrderByMemberCountDesc(String keyword, String categoryVal, Integer lastMemberCount, Long roomId, int pageSize); | ||
|
Comment on lines
+18
to
+21
Contributor
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. 네이밍 굿! 가독성 좋네요 |
||
|
|
||
| List<RoomRecruitingDetailViewResponse.RecommendRoom> findOtherRecruitingRoomsByCategoryOrderByStartDateAsc(Long roomId, String category, int count); | ||
|
|
||
| Page<RoomGetHomeJoinedListResponse.RoomSearchResult> searchHomeJoinedRooms(Long userId, LocalDate today, Pageable pageable); | ||
| Page<RoomGetHomeJoinedListResponse.JoinedRoomInfo> searchHomeJoinedRooms(Long userId, LocalDate today, Pageable pageable); | ||
|
|
||
| List<RoomQueryDto> findRecruitingRoomsUserParticipated(Long userId, LocalDate dateCursor, Long roomIdCursor, int pageSize); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
오탈자 수정: ‘첵제목’ → ‘책제목’
사용자 문서에 노출되는 스웨거 설명의 오탈자를 바로잡아 주세요.
적용 diff:
📝 Committable suggestion
🤖 Prompt for AI Agents
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.
예리하시다
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.
@buzz0331, 감사합니다! 사용자에게 노출되는 문서의 품질이 중요하다고 생각합니다. 😊