Skip to content

[hotfix] 내 모임방 리스트 조회 api 수정#153

Merged
seongjunnoh merged 6 commits intodevelopfrom
hotfix/#151/room-show-mine-response-data-add
Aug 6, 2025
Merged

[hotfix] 내 모임방 리스트 조회 api 수정#153
seongjunnoh merged 6 commits intodevelopfrom
hotfix/#151/room-show-mine-response-data-add

Conversation

@seongjunnoh
Copy link
Collaborator

@seongjunnoh seongjunnoh commented Aug 6, 2025

#️⃣ 연관된 이슈

closes #151

📝 작업 내용

@rbqks529 님의 요청으로 조회한 방이 [모집중, 진행중, 완료된] 상태 중 어떤 상태인지를 알 수 있도록 response dto 를 수정하였습니다

현재 api는 request param의 값에 의해 내가 참여한 모임방 중 [모집중, 진행중, 모집+진행중, 완료된] 방을 조회할 수 있는데,

  • 모집중, 진행중, 완료된 모임방 조회일 경우 : request param 의 값에 해당하는 방들을 조회 + 이 값을 그대로 응답
  • 모집+진행중 일 경우 : 모집+진행중인 방 조회 + 조회한 방이 어떤 방인지를 분기처리하여 응답

하도록 api 를 수정하였습니다

📸 스크린샷

image

-> 모집+진행 중인 방으로 조회해도 recruiting 으로 응답이 오는것을 확인할 수 있습니다

💬 리뷰 요구사항

RoomQueryDto 를 수정한 부분 확인해 주시면 감사하겠습니다! @buzz0331 @hd0rable

📌 PR 진행 시 이러한 점들을 참고해 주세요

* P1 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
* P2 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
* P3 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

Summary by CodeRabbit

  • 신규 기능

    • 내가 참여 중인 방 목록 응답에 방 상태(type) 정보가 추가되어, 모집중/진행중/완료됨을 구분할 수 있습니다.
    • 각 방의 시작일(startDate) 정보가 제공됩니다.
  • 개선 사항

    • 방 상태 및 남은 기간(endDate) 필드에 대한 설명이 API 문서(Swagger)에 추가되어 이해가 쉬워졌습니다.
    • 방 상태 판별 로직이 개선되어, 방의 실제 상태에 따라 정확한 정보가 제공됩니다.

- 기존 코드의 수정을 피하기 위해 기존 dto 버전의 @QueryProjection 생성자 추가
- 모집 + 진행중인 방 조회일 경우, 조회한 방의 "진행 시작일" 과 현재요일을 비교해 모집중인 방인지, 진행중인 방인지 구분하는 로직 추가
- enum 의존성을 추가하여 response 로 매핑할 방의 상태 또한 매핑하도록 수정
@seongjunnoh seongjunnoh linked an issue Aug 6, 2025 that may be closed by this pull request
2 tasks
@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

유저가 참여한 모임방 API의 응답 데이터에 방 상태를 나타내는 type 필드가 추가되었습니다. 이를 위해 DTO, 매퍼, 서비스, OpenAPI 스키마에 관련 필드와 매핑 로직이 도입 및 수정되었으며, 방의 시작일(startDate) 정보도 쿼리 결과에 포함되어 상태 판별에 활용됩니다.

Changes

Cohort / File(s) Change Summary
OpenAPI 스키마 및 응답 구조 개선
src/main/java/konkuk/thip/room/adapter/in/web/response/RoomShowMineResponse.java
RoomShowMineResponse와 내부 MyRoom에 OpenAPI 스키마 설명 추가, type 필드 신설 및 설명 추가, endDate 필드에 설명 부여
쿼리 DTO 확장
src/main/java/konkuk/thip/room/application/port/out/dto/RoomQueryDto.java
startDate(nullable) 필드 추가, 이를 위한 생성자 오버로딩 및 기존 생성자 수정
쿼리 구현부 수정
src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java
방 조회 쿼리에서 room.startDate를 DTO에 포함하도록 수정
매퍼 시그니처 및 매핑 로직 변경
src/main/java/konkuk/thip/room/application/mapper/RoomQueryMapper.java
toShowMyRoomResponse 메서드에 MyRoomType 컨텍스트 파라미터 추가, type 필드 매핑 로직 반영
서비스 로직 개선
src/main/java/konkuk/thip/room/application/service/RoomShowMineService.java
MyRoomType import 경로 변경, PLAYING_AND_RECRUITING 상태 구분을 위해 startDate와 오늘 날짜를 비교하여 PLAYING/RECRUITING 판별 및 매핑 방식 개선
타입 클래스 위치 이동
src/main/java/konkuk/thip/room/application/port/in/dto/MyRoomType.java
MyRoomType 클래스의 패키지 경로를 도메인에서 애플리케이션 포트 입력 DTO로 이동

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RoomShowMineService
    participant RoomQueryRepositoryImpl
    participant RoomQueryMapper

    User->>RoomShowMineService: getMyRooms(userId, type, cursor)
    RoomShowMineService->>RoomQueryRepositoryImpl: fetchMyRooms(userId, ...)
    RoomQueryRepositoryImpl-->>RoomShowMineService: List<RoomQueryDto> (with startDate)
    loop for each RoomQueryDto
        RoomShowMineService->>RoomQueryMapper: toShowMyRoomResponse(dto, myRoomType)
        RoomQueryMapper-->>RoomShowMineService: MyRoom (with type)
    end
    RoomShowMineService-->>User: RoomShowMineResponse (with MyRoom.type)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
유저가 참여한 모임방 api response에 방 상태를 나타내는 String type 추가 (#151)

Assessment against linked issues: Out-of-scope changes

(해당 변경사항 내에 목적 외의 코드 변경은 발견되지 않았습니다.)

Possibly related PRs

Suggested labels

⚡️ fix, 🛠️ feat, 🍀 refactor

Suggested reviewers

  • buzz0331

Poem

방의 상태, 이제 명확하게 type으로!
모집, 진행, 완료까지 한눈에 쏙쏙,
DTO도 매퍼도 새 옷 입고,
🐇 토끼는 코드를 살짝쿵 훑고,
모임방 응답, 더 똑똑해졌네!
오늘도 코드밭에 당근 한 송이~ 🥕

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/#151/room-show-mine-response-data-add

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@seongjunnoh seongjunnoh requested a review from buzz0331 August 6, 2025 08:09
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/konkuk/thip/room/adapter/in/web/response/RoomShowMineResponse.java (1)

19-21: endDate 필드의 Swagger 설명 문구 개선 필요

“완료된 방은 쓰레기값이 넘어갑니다. 무시해주세요.” 라는 표현은 API 문서에 포함하기엔 부적절합니다.
완료된 방이라면 null 또는 빈 문자열을 반환하도록 스펙을 정의하고, 설명도 이에 맞게 수정하는 편이 좋습니다.
예시:

-@Schema(description = "방 진행 마감일 or 방 모집 마감일까지 남은 시간 (ex. \"3일 뒤\"), 완료된 방은 쓰레기값이 넘어갑니다. 무시해주세요.")
+@Schema(description = "방 진행 마감일 · 모집 마감일까지 남은 시간(예: \"3일 뒤\"). 완료된 방의 경우 null 반환")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 936e8b1 and aac0333.

📒 Files selected for processing (6)
  • src/main/java/konkuk/thip/room/adapter/in/web/response/RoomShowMineResponse.java (2 hunks)
  • src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (1 hunks)
  • src/main/java/konkuk/thip/room/application/mapper/RoomQueryMapper.java (2 hunks)
  • src/main/java/konkuk/thip/room/application/port/in/dto/MyRoomType.java (1 hunks)
  • src/main/java/konkuk/thip/room/application/port/out/dto/RoomQueryDto.java (3 hunks)
  • src/main/java/konkuk/thip/room/application/service/RoomShowMineService.java (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: hd0rable
PR: THIP-TextHip/THIP-Server#57
File: src/test/java/konkuk/thip/room/domain/RoomTest.java:0-0
Timestamp: 2025-07-08T16:30:33.771Z
Learning: Room 도메인에서 startDate는 현재 날짜 이후여야 하는 도메인 규칙이 있어서, 테스트에서 만료된 상태를 시뮬레이션하려면 reflection을 사용해야 한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#113
File: src/main/java/konkuk/thip/recentSearch/adapter/out/persistence/RecentSearchCommandPersistenceAdapter.java:38-44
Timestamp: 2025-07-30T14:05:04.945Z
Learning: seongjunnoh는 코드 최적화 제안에 대해 구체적인 기술적 근거와 효율성 차이를 이해하고 싶어하며, 성능 개선 방식에 대한 상세한 설명을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#93
File: src/main/java/konkuk/thip/room/adapter/out/persistence/RoomQueryPersistenceAdapter.java:49-114
Timestamp: 2025-07-28T16:44:31.224Z
Learning: seongjunnoh는 코드 중복 문제에 대한 리팩토링 제안을 적극적으로 수용하고 함수형 인터페이스를 활용한 해결책을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#112
File: src/main/java/konkuk/thip/feed/adapter/out/persistence/repository/FeedQueryRepositoryImpl.java:272-272
Timestamp: 2025-07-30T10:44:34.115Z
Learning: seongjunnoh는 피드 커서 페이지네이션에서 LocalDateTime 단일 커서 방식을 선호하며, 복합 키 기반 커서보다 구현 단순성과 성능을 우선시한다.
📚 Learning: room 도메인에서 startdate는 현재 날짜 이후여야 하는 도메인 규칙이 있어서, 테스트에서 만료된 상태를 시뮬레이션하려면 reflection을 사용해야 한다....
Learnt from: hd0rable
PR: THIP-TextHip/THIP-Server#57
File: src/test/java/konkuk/thip/room/domain/RoomTest.java:0-0
Timestamp: 2025-07-08T16:30:33.771Z
Learning: Room 도메인에서 startDate는 현재 날짜 이후여야 하는 도메인 규칙이 있어서, 테스트에서 만료된 상태를 시뮬레이션하려면 reflection을 사용해야 한다.

Applied to files:

  • src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java
  • src/main/java/konkuk/thip/room/application/port/out/dto/RoomQueryDto.java
  • src/main/java/konkuk/thip/room/adapter/in/web/response/RoomShowMineResponse.java
📚 Learning: thip 프로젝트에서는 cqrs port 분리 시 다음 컨벤션을 따름: commandport에는 findbyxxx를 통해 도메인 엔티티를 찾아오는 메서드를 추가하고, querypo...
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#43
File: src/main/java/konkuk/thip/book/application/port/out/BookCommandPort.java:0-0
Timestamp: 2025-07-03T03:05:05.031Z
Learning: THIP 프로젝트에서는 CQRS Port 분리 시 다음 컨벤션을 따름: CommandPort에는 findByXXX를 통해 도메인 엔티티를 찾아오는 메서드를 추가하고, QueryPort에는 조회 API의 response에 해당하는 데이터들을 DB로부터 조회하는 메서드를 추가함.

Applied to files:

  • src/main/java/konkuk/thip/room/application/service/RoomShowMineService.java
  • src/main/java/konkuk/thip/room/application/port/out/dto/RoomQueryDto.java
📚 Learning: thip 프로젝트에서는 query api(조회 api)에 한해서는 application 계층에서 adapter.in.web.response 패키지의 response dto를 직접 ...
Learnt from: buzz0331
PR: THIP-TextHip/THIP-Server#78
File: src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java:3-3
Timestamp: 2025-07-14T18:22:56.538Z
Learning: THIP 프로젝트에서는 Query API(조회 API)에 한해서는 application 계층에서 adapter.in.web.response 패키지의 response DTO를 직접 참조하는 것을 허용함. 이는 CQRS 아키텍처에서 읽기 전용 작업의 효율성을 위한 팀 컨벤션임.

Applied to files:

  • src/main/java/konkuk/thip/room/application/port/out/dto/RoomQueryDto.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (8)
src/main/java/konkuk/thip/room/application/port/in/dto/MyRoomType.java (1)

1-1: 패키지 위치 변경이 적절합니다.

MyRoomType을 도메인 패키지에서 애플리케이션 포트 입력 DTO 패키지로 이동한 것이 적절합니다. 이제 이 클래스가 매퍼의 컨텍스트 파라미터로 사용되므로 현재 위치가 더 적합합니다.

src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (1)

432-432: 방 시작일 정보 추가가 적절합니다.

room.startDate를 DTO 프로젝션에 추가하여 서비스 레이어에서 방의 진행/모집 상태를 정확히 판별할 수 있도록 지원합니다. 이는 새로 추가된 RoomQueryDtostartDate 필드와 일치합니다.

src/main/java/konkuk/thip/room/application/mapper/RoomQueryMapper.java (2)

7-8: 필요한 import 추가가 적절합니다.

MyRoomType@Context 어노테이션 import가 새로운 매핑 로직을 위해 적절히 추가되었습니다.


22-24: 매퍼 메서드 개선이 잘 구현되었습니다.

@Context 어노테이션을 사용하여 MyRoomType 파라미터를 추가하고, 이를 통해 type 필드를 매핑하는 구현이 적절합니다. 기존 endDate 매핑은 유지되어 호환성을 보장합니다.

src/main/java/konkuk/thip/room/application/port/out/dto/RoomQueryDto.java (2)

4-4: nullable startDate 필드 추가가 적절합니다.

방의 시작일 정보를 담을 startDate 필드가 @Nullable로 적절히 추가되었습니다. 모든 쿼리에서 이 정보가 필요하지 않을 수 있으므로 nullable 설계가 합리적입니다.

Also applies to: 17-17


30-40: 하위 호환성을 위한 오버로드 생성자가 잘 구현되었습니다.

기존 코드와의 호환성을 위해 startDate 없이 객체를 생성할 수 있는 오버로드 생성자를 제공한 것이 적절합니다. @QueryProjection 어노테이션도 올바르게 적용되었습니다.

src/main/java/konkuk/thip/room/application/service/RoomShowMineService.java (2)

10-10: 패키지 변경에 따른 import 수정이 적절합니다.

MyRoomType의 패키지 위치 변경에 따라 import가 올바르게 업데이트되었습니다.


46-61: dto.startDate는 null이 될 수 없습니다

Room 엔티티 생성 시 startDate는 필수 값으로 설정되며, QRoomQueryDto 생성에서도 항상 room.startDate를 전달하도록 되어 있습니다. 따라서 해당 분기에서 dto.startDate가 null이 되는 상황은 발생하지 않으므로 별도의 null 검사를 추가하거나 처리할 필요가 없습니다.

Likely an incorrect or invalid review comment.

Comment on lines +22 to +23
@Schema(description = "방 상태 : [모집중(=recruiting), 진행중(=playing), 완료된(=expired)] 중 하나")
String type
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

typeString으로 노출하면 타입 안정성이 사라집니다

이미 애플리케이션 계층에 MyRoomType enum이 존재하므로 응답 DTO에도 동일한 enum을 사용해 일관성과 컴파일 타임 검증을 확보하는 편이 좋습니다. Swagger 문서에서도 자동으로 enum 값이 노출됩니다.

-@Schema(description = "방 상태 : [모집중(=recruiting), 진행중(=playing), 완료된(=expired)] 중 하나")
-String type
+@Schema(description = "방 상태")
+MyRoomType type

이렇게 변경하면 매퍼 단에서 type.name().toLowerCase()와 같은 문자열 변환 로직도 제거할 수 있어 중복이 줄어듭니다.
단, 패키지 순환 의존성 여부는 확인이 필요합니다.

🤖 Prompt for AI Agents
In
src/main/java/konkuk/thip/room/adapter/in/web/response/RoomShowMineResponse.java
around lines 22 to 23, the field 'type' is currently declared as a String, which
loses type safety. Change the type of 'type' from String to the existing enum
'MyRoomType' used in the application layer to ensure consistency and enable
compile-time validation. This also allows removal of string conversion logic
like 'type.name().toLowerCase()' in the mapper. Before applying this change,
verify that it does not introduce package cyclic dependencies.

Copy link
Contributor

@buzz0331 buzz0331 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿굿!!

Comment on lines +30 to +40
@QueryProjection
public RoomQueryDto(
Long roomId,
String bookImageUrl,
String roomName,
int recruitCount,
int memberCount,
LocalDate endDate
) {
this(roomId, bookImageUrl, roomName, recruitCount, memberCount, null, endDate);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 오버로딩을 사용해서 코드 수정을 최소화했네요!! 역시 예리하심 👍🏻 👍🏻

Comment on lines +23 to +24
@Mapping(target = "type", expression = "java(myRoomType.getType())")
RoomShowMineResponse.MyRoom toShowMyRoomResponse(RoomQueryDto dto, @Context MyRoomType myRoomType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 MyRoomType이라는 외부 ENUM을 가져오기 위해 @Context가 사용된걸로 이해하면 되나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 response에 enum 타입이 없으므로 mapStruct가 enum은 매핑을 위해 문자열을 꺼내오는 용도로만 사용하도록 명시하기 위해 @context 어노테이션을 활용하였습니다!

Comment on lines +48 to +58
if (myRoomType != MyRoomType.PLAYING_AND_RECRUITING) {
// PLAYING, RECRUITING, EXPIRED 경우 타입 그대로 전달
return roomQueryMapper.toShowMyRoomResponse(dto, myRoomType);
}

// PLAYING_AND_RECRUITING: startDate 기준으로 진행중/모집중 구분
LocalDate now = LocalDate.now();
if (dto.startDate() != null && dto.startDate().isBefore(now)) {
return roomQueryMapper.toShowMyRoomResponse(dto, MyRoomType.PLAYING); // 진행중인 방
} else {
return roomQueryMapper.toShowMyRoomResponse(dto, MyRoomType.RECRUITING); // 모집중인 방
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +19 to +23
@Schema(description = "방 진행 마감일 or 방 모집 마감일까지 남은 시간 (ex. \"3일 뒤\"), 완료된 방은 쓰레기값이 넘어갑니다. 무시해주세요.")
String endDate, // 방 진행 마감일 or 방 모집 마감일 (~ 뒤 형식)

@Schema(description = "방 상태 : [모집중(=recruiting), 진행중(=playing), 완료된(=expired)] 중 하나")
String type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@seongjunnoh seongjunnoh merged commit 5f17e7f into develop Aug 6, 2025
2 checks passed
@seongjunnoh seongjunnoh deleted the hotfix/#151/room-show-mine-response-data-add branch August 6, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[THIP2025-213] [hotfix] 유저가 참여한 모임방 api response 수정

2 participants