Skip to content

[WTH-326] 게시판 관련 API에 boardId 필드 추가#58

Open
soo0711 wants to merge 6 commits intodevfrom
fix/WTH-326-게시판-관련-API에-boardId-필드-추가

Hidden character warning

The head ref may contain hidden characters: "fix/WTH-326-\uac8c\uc2dc\ud310-\uad00\ub828-API\uc5d0-boardId-\ud544\ub4dc-\ucd94\uac00"
Open

[WTH-326] 게시판 관련 API에 boardId 필드 추가#58
soo0711 wants to merge 6 commits intodevfrom
fix/WTH-326-게시판-관련-API에-boardId-필드-추가

Conversation

@soo0711
Copy link
Copy Markdown
Collaborator

@soo0711 soo0711 commented Apr 25, 2026

📌 Summary

어떤 작업인지 한 줄 요약해 주세요.

board와 관련된 응답에 boardId를 추가했습니다.

📝 Changes

변경사항을 what, why, how로 구분해 작성해 주세요.

What

최신 게시글, 최신 공지, 읽지 않은 공지, 게시글 저장 응답에 boardId 추가

Why

프론트의 라우팅 변경에 따라 boardId를 추가했습니다.

How

boardId 추가

📸 Screenshots / Logs

필요시 스크린샷 or 로그를 첨부해주세요.

💡 Reviewer 참고사항

리뷰에 참고할 내용을 작성해주세요.

✅ Checklist

  • PR 제목 설정 완료 (WTH-123 인증 필터 설정)
  • 테스트 구현 완료
  • 리뷰어 등록 완료
  • 자체 코드 리뷰 완료

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 게시물/대시보드 응답에 게시판 ID(boardId) 포함
    • 좋아요 관련 응답에 게시판 ID, 좋아요 상태 및 카운트 정보 추가
    • 게시물 조회·수정·삭제·좋아요 API 경로에 게시판 ID를 경로 인자로 추가
  • 유지보수 / 버그 수정

    • 요청된 게시판 ID와 게시물 소속 불일치 시 오류 응답 추가(검증 강화)
  • 테스트

    • 관련 유스케이스 및 쿼리/컨트롤러 단위 테스트 업데이트 및 불일치 예외 테스트 추가

@soo0711 soo0711 requested review from hyxklee and nabbang6 April 25, 2026 16:52
@soo0711 soo0711 self-assigned this Apr 25, 2026
@soo0711 soo0711 added the 🐞 BugFix 버그 수정 label Apr 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Warning

Rate limit exceeded

@soo0711 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 55 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7d0a180-26e3-48e7-9ca9-a76d1fe473f3

📥 Commits

Reviewing files that changed from the base of the PR and between f3b8601 and 6b31f1c.

📒 Files selected for processing (2)
  • src/main/kotlin/com/weeth/domain/board/application/dto/request/CreateBoardRequest.kt
  • src/main/kotlin/com/weeth/domain/board/application/dto/request/UpdateBoardRequest.kt
📝 Walkthrough

Walkthrough

여러 게시판 관련 엔드포인트와 DTO에 boardId: Long 필드를 추가하고, 컨트롤러→유스케이스/쿼리→매퍼 흐름에서 URL의 boardId를 전달·검증하도록 호출 시그니처와 매핑 로직을 확장했습니다. 테스트들도 이에 맞춰 업데이트되었습니다.

Changes

Cohort / File(s) Summary
Post 응답 DTO / Like DTO
src/main/kotlin/com/weeth/domain/board/application/dto/response/PostSaveResponse.kt, src/main/kotlin/com/weeth/domain/board/application/dto/response/PostLikeActionResponse.kt
boardId: Long 필드 추가(PostSaveResponse) 및 새로운 PostLikeActionResponse DTO 추가( boardId, isLiked, likeCount ). Swagger 스키마 주석 포함.
Dashboard 응답 DTO
src/main/kotlin/com/weeth/domain/dashboard/application/dto/response/DashboardNoticeResponse.kt, .../DashboardPostResponse.kt, .../DashboardUnreadNoticeResponse.kt
각 DTO에 boardId: Long 필드 추가 및 Swagger 스키마 주석 적용.
매퍼 변경
src/main/kotlin/com/weeth/domain/board/application/mapper/PostMapper.kt, src/main/kotlin/com/weeth/domain/dashboard/application/mapper/DashboardMapper.kt
post.board.idboardId로 매핑하도록 toSaveResponse 등 항목 수정. toLikeActionResponse 새로 추가.
컨트롤러 경로/시그니처
src/main/kotlin/com/weeth/domain/board/presentation/PostController.kt
경로에 /{boardId} 추가, 관련 핸들러 시그니처에 @PathVariable boardId: Long 추가. like/unlike 응답 타입을 PostLikeActionResponse로 변경.
유스케이스/쿼리 변경
src/main/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostUseCase.kt, .../ManagePostLikeUseCase.kt, src/main/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryService.kt
update/delete/findPost/like·unlike 메서드에 boardId 파라미터 추가. 조회 시 post.board.id == boardId 검증을 추가해 불일치 시 BoardNotFoundException 발생. 반환 타입 및 매퍼 호출 변경.
테스트 업데이트
src/test/kotlin/com/weeth/domain/board/.../ManagePostUseCaseTest.kt, .../ManagePostLikeUseCaseTest.kt, .../GetPostQueryServiceTest.kt, .../GetDashboardQueryServiceTest.kt
테스트에서 새로운 boardId 인자 전달 및 매퍼/응답 변경 반영. 불일치한 boardId에 대한 BoardNotFoundException 검증 테스트 추가.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • nabbang6
  • hyxklee

Poem

🐰 보드 아이디 하나 꿀꺽 넣었네,
매퍼가 전해주고 컨트롤러가 불러오네.
검증 통과하면 DTO 깜짝 등장,
테스트도 같이 뛰어노네—토끼가 깡충! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심인 보드 관련 API에 boardId 필드 추가를 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명이 제공된 템플릿의 대부분 섹션을 포함하고 있으나, 'How' 섹션이 과도하게 간단하고 'Screenshots / Logs' 섹션이 비어있습니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/WTH-326-게시판-관련-API에-boardId-필드-추가

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@@ -5,4 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema
data class PostSaveResponse(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

게시글 상세조회, 게시글 좋아요, 게시글 좋아요 취소, 게시글 삭제, 전체 게시글 조회에도 BoardId를 추가하면 좋을 것 같은데 어떻게 생각하시나요??
전반적으로 모두 BoardId를 함께 관리하도록이요! Req/Res 모두 혹은 적절하게 배치해서용

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

넵! 좋습니당! 다시 수정해보겟습니당

Copy link
Copy Markdown

@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.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d9664c and f3b8601.

📒 Files selected for processing (9)
  • src/main/kotlin/com/weeth/domain/board/application/dto/response/PostLikeActionResponse.kt
  • src/main/kotlin/com/weeth/domain/board/application/mapper/PostMapper.kt
  • src/main/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostLikeUseCase.kt
  • src/main/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostUseCase.kt
  • src/main/kotlin/com/weeth/domain/board/application/usecase/query/GetPostQueryService.kt
  • src/main/kotlin/com/weeth/domain/board/presentation/PostController.kt
  • src/test/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostLikeUseCaseTest.kt
  • src/test/kotlin/com/weeth/domain/board/application/usecase/command/ManagePostUseCaseTest.kt
  • src/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants