[WTH-326] 게시판 관련 API에 boardId 필드 추가#58
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 55 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough여러 게시판 관련 엔드포인트와 DTO에 Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller as "PostController\n(`@PathVariable` boardId)"
participant UseCase as "ManagePostLikeUseCase\n/ GetPostQueryService"
participant Repo as "PostRepository"
participant Mapper as "PostMapper"
Client->>Controller: 요청 (/{boardId}/posts/{postId}/...)
Controller->>UseCase: 호출 (clubId, boardId, postId, userId, ...)
UseCase->>Repo: 게시글 조회 및 락 (findByIdWithLock/postId)
Repo-->>UseCase: Post 엔티티
UseCase->>UseCase: 검증 (post.board.id == boardId?)\n권한/상태 검사
alt 검증 통과
UseCase->>Mapper: 매핑 (toLikeActionResponse / toSaveResponse)
Mapper-->>UseCase: DTO(boardId 포함)
UseCase-->>Controller: DTO 반환
Controller-->>Client: HTTP 응답 (DTO 포함)
else 검증 실패
UseCase-->>Controller: BoardNotFoundException
Controller-->>Client: HTTP 404
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| @@ -5,4 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema | |||
| data class PostSaveResponse( | |||
There was a problem hiding this comment.
게시글 상세조회, 게시글 좋아요, 게시글 좋아요 취소, 게시글 삭제, 전체 게시글 조회에도 BoardId를 추가하면 좋을 것 같은데 어떻게 생각하시나요??
전반적으로 모두 BoardId를 함께 관리하도록이요! Req/Res 모두 혹은 적절하게 배치해서용
There was a problem hiding this comment.
넵! 좋습니당! 다시 수정해보겟습니당
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryService.kt (1)
56-59: boardId 불일치 시 예외 종류 및 검사 순서 재고
post.board.id != boardId일 때BoardNotFoundException을 던지고 있는데, 바로 다음 줄에서post.board.club.id != clubId인 동일하게 “이 URL로는 게시글을 찾을 수 없는” 상황은PostNotFoundException으로 처리됩니다. 두 케이스의 사용자 관점은 동일하므로 응답이 갈리는 게 어색하고, 검사 순서상 다른 클럽 소속 게시글에 대해boardId를 변경해 가며 시도하면 어떤 boardId가 그 post의 실제 board인지 외부에서 좁혀낼 여지가 있습니다.가능한 두 가지 정리:
- 클럽 소속 검사를 먼저 수행하고, 그 뒤에 boardId 일치 여부를 확인.
- boardId 불일치도
PostNotFoundException으로 통일(또는validateBoardVisibility를 호출해 board 자체의 존재/접근권한까지 한 번에 검증).♻️ 예시 정리(클럽 → board 순서로 재배치)
- if (post.board.id != boardId) throw BoardNotFoundException() - if (post.board.club.id != clubId || post.board.isDeleted || !post.board.isAccessibleBy(member.memberRole)) { - throw PostNotFoundException() - } + if (post.board.club.id != clubId || post.board.isDeleted || !post.board.isAccessibleBy(member.memberRole)) { + throw PostNotFoundException() + } + if (post.board.id != boardId) throw PostNotFoundException()같은 패턴이
ManagePostUseCase.update/delete(L77, L100)와ManagePostLikeUseCase.getValidatedPostWithLike(L80)에도 동일하게 들어가 있어서 함께 정리하면 일관성이 좋아집니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryService.kt` around lines 56 - 59, The current check in GetPostQueryService (and the same pattern in ManagePostUseCase.update/delete and ManagePostLikeUseCase.getValidatedPostWithLike) throws BoardNotFoundException when post.board.id != boardId but PostNotFoundException for other visibility/club mismatches, leaking information; change the logic to either (A) validate club membership/visibility first then check boardId, or (B) treat a boardId mismatch as PostNotFoundException so all “not found / inaccessible” cases yield the same error; update the checks inside GetPostQueryService (and mirror the same fix in ManagePostUseCase.update, ManagePostUseCase.delete, and ManagePostLikeUseCase.getValidatedPostWithLike) so they either call a single validateBoardVisibility/post visibility helper (e.g., validateBoardVisibility) or reorder/replace the exceptions to consistently throw PostNotFoundException for inaccessible or mismatched board cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/main/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryService.kt`:
- Around line 56-59: The current check in GetPostQueryService (and the same
pattern in ManagePostUseCase.update/delete and
ManagePostLikeUseCase.getValidatedPostWithLike) throws BoardNotFoundException
when post.board.id != boardId but PostNotFoundException for other
visibility/club mismatches, leaking information; change the logic to either (A)
validate club membership/visibility first then check boardId, or (B) treat a
boardId mismatch as PostNotFoundException so all “not found / inaccessible”
cases yield the same error; update the checks inside GetPostQueryService (and
mirror the same fix in ManagePostUseCase.update, ManagePostUseCase.delete, and
ManagePostLikeUseCase.getValidatedPostWithLike) so they either call a single
validateBoardVisibility/post visibility helper (e.g., validateBoardVisibility)
or reorder/replace the exceptions to consistently throw PostNotFoundException
for inaccessible or mismatched board cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c8ac3586-ad5c-4085-b283-b77e51ce2f38
📒 Files selected for processing (9)
src/main/kotlin/com/weeth/domain/board/application/dto/response/PostLikeActionResponse.ktsrc/main/kotlin/com/weeth/domain/board/application/mapper/PostMapper.ktsrc/main/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostLikeUseCase.ktsrc/main/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostUseCase.ktsrc/main/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryService.ktsrc/main/kotlin/com/weeth/domain/board/presentation/PostController.ktsrc/test/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostLikeUseCaseTest.ktsrc/test/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostUseCaseTest.ktsrc/test/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryServiceTest.kt
✅ Files skipped from review due to trivial changes (1)
- src/main/kotlin/com/weeth/domain/board/application/dto/response/PostLikeActionResponse.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/kotlin/com/weeth/domain/board/application/mapper/PostMapper.kt
📌 Summary
board와 관련된 응답에 boardId를 추가했습니다.
📝 Changes
What
최신 게시글, 최신 공지, 읽지 않은 공지, 게시글 저장 응답에 boardId 추가
Why
프론트의 라우팅 변경에 따라 boardId를 추가했습니다.
How
boardId 추가
📸 Screenshots / Logs
💡 Reviewer 참고사항
✅ Checklist
Summary by CodeRabbit
릴리스 노트
새로운 기능
유지보수 / 버그 수정
테스트