-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 내가 참여한 모임방 목록 조회 #93
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
Changes from all commits
6951407
89cb069
ae89b3c
73cf3f6
e36a8ef
87b1861
d8e5b1a
a767a9e
03fc6bf
21d31ca
5376d0e
a65a1ea
7f40f4c
9d9b3b8
1a3f220
1f35fde
4852a13
d3f4f93
65f8c9c
7b7dd91
2d934ff
12c305d
472710f
3d39ed4
49ff254
8da1411
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package konkuk.thip.room.adapter.in.web.response; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record RoomShowMineResponse( | ||
| List<MyRoom> roomList, | ||
| String nextCursor, | ||
| boolean isLast | ||
| ) { | ||
| public record MyRoom( | ||
| Long roomId, | ||
| String bookImageUrl, | ||
| String roomName, | ||
| int memberCount, | ||
| String endDate // 방 진행 마감일 or 방 모집 마감일 (~ 뒤 형식) | ||
| ) {} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,4 +69,9 @@ public RoomJpaEntity updateFrom(Room room) { | |
| this.memberCount = room.getMemberCount(); | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| // 테스트 메서드 편의용 | ||
|
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. p3: 이건 나즁에,, 리펙토링하는게 좋아보여욥
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. @buzz0331 @hd0rable 저희가 RoomJpaEntity 에 memberCount 값을 추가하여서 기존 테스트 코드 작성시 특정 방에 어떤 유저가 속해있다 라는 상황을 가정할때 더이상 RoomParticipantJpaEntity 를 DB에 save 하지 않고, room의 memberCount 값을 수정함으로써 테스트 코드를 간결하게 작성할 수 있는 이점이 있지 않을까 생각하긴 합니다 이런 이유로 RoomJpaEntity에 updateMemberCount 라는 메서드를 추가하였고, jpa entity 는 외부로 노출되는 메서드가 아니니 테스트 메서드 편의용으로 괜찮지 않나라는 생각이긴 합니다 관련해서 어떻게 생각하시나요?
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.
다만 JPA 엔티티는 도메인-DB 매핑과 정합성을 책임지는 계층이기 때문에, 그래도 간편성 차원에선 고려 해볼법한 방법이라 생각하며, 유지한다면 명확히
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. 오 @VisibleForTesting 어노테이션을 통한 문서화도 좋은 방법인것 같습니다!! @buzz0331 현준님 생각은 어떠신가요?
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. 테스트 편의를 위해 update 메서드 뚫어놓는 것은 좋은 것 같아요! 특정 테스트 환경을 만들기 위해서는 불가피할 것 같습니다. 저도 저번에 방 참여 api의 테스트코드를 작성하기 위해서 @VisibleForTesting을 도입해서 updateStartDate 메서드를 구현해두었는데 테스트에서도 접근이 가능하고, 서비스 코드에서도 접근이 가능하더라구요,, @VisibleForTesting이 하는 역할이 정확히 어떤건지 아시나요??
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. @VisibleForTesting도 사실상 주석처럼 "테스트에서만 사용하겠다"라는걸 명시하는 어노테이션으로 사용한다고 하네요
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. 아하 접근 제한자를 실제로 변경해주는 것은 아니고 주석 정도의 역할이군요! 주석을 사용하는 것보다 조금더 명시적일 것 같아서 좋을 것 같네요!! |
||
| public void updateMemberCount(int memberCount) { | ||
| this.memberCount = memberCount; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,14 @@ | ||
| package konkuk.thip.room.adapter.out.persistence; | ||
|
|
||
| import konkuk.thip.common.util.Cursor; | ||
| import konkuk.thip.common.util.CursorBasedList; | ||
| 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.adapter.out.mapper.RoomMapper; | ||
| import konkuk.thip.room.adapter.out.persistence.repository.RoomJpaRepository; | ||
| import konkuk.thip.room.application.port.out.RoomQueryPort; | ||
| import konkuk.thip.room.application.port.out.dto.RoomShowMineQueryDto; | ||
| import konkuk.thip.room.domain.Room; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
|
|
@@ -41,4 +44,44 @@ public List<RoomRecruitingDetailViewResponse.RecommendRoom> findOtherRecruitingR | |
| public Page<RoomGetHomeJoinedListResponse.RoomSearchResult> searchHomeJoinedRooms(Long userId, LocalDate date, Pageable pageable) { | ||
| return roomJpaRepository.searchHomeJoinedRooms(userId, date, pageable); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomShowMineQueryDto> findRecruitingRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(userId, cursor, roomJpaRepository::findRecruitingRoomsUserParticipated); | ||
|
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. 오호 엄청 간단해지네여 👍🏻 |
||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomShowMineQueryDto> findPlayingRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(userId, cursor, roomJpaRepository::findPlayingRoomsUserParticipated); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomShowMineQueryDto> findPlayingAndRecruitingRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(userId, cursor, roomJpaRepository::findPlayingAndRecruitingRoomsUserParticipated); | ||
| } | ||
|
|
||
| @Override | ||
| public CursorBasedList<RoomShowMineQueryDto> findExpiredRoomsUserParticipated(Long userId, Cursor cursor) { | ||
| return findRooms(userId, cursor, roomJpaRepository::findExpiredRoomsUserParticipated); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| private interface RoomQueryFunction { | ||
| List<RoomShowMineQueryDto> apply(Long userId, LocalDate lastLocalDate, Long lastId, int pageSize); | ||
| } | ||
|
|
||
| private CursorBasedList<RoomShowMineQueryDto> findRooms(Long userId, Cursor cursor, RoomQueryFunction queryFunction) { | ||
| LocalDate lastLocalDate = cursor.isFirstRequest() ? null : cursor.getLocalDate(0); | ||
| Long lastId = cursor.isFirstRequest() ? null : cursor.getLong(1); | ||
| int pageSize = cursor.getPageSize(); | ||
|
|
||
| List<RoomShowMineQueryDto> dtos = queryFunction.apply(userId, lastLocalDate, lastId, pageSize); | ||
| return CursorBasedList.of(dtos, pageSize, roomShowMineQueryDto -> { | ||
| Cursor nextCursor = new Cursor(List.of( | ||
| roomShowMineQueryDto.endDate().toString(), | ||
| roomShowMineQueryDto.roomId().toString() | ||
| )); | ||
| return nextCursor.toEncodedString(); | ||
| }); | ||
| } | ||
| } | ||
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.
LGTM