[BE-29] AddCommentUseCase 확장 (모임 소속 댓글 작성 인가, FR-3)
작업 내용 (설계 의도)
변경 사항
근거 TDD: 20260707-post-community-연동-tdd.md Detail Design.
AddCommentUseCase(application/post/usecase/AddCommentUseCase.kt)에 CommunityDomainService를 주입해 community-aware로 확장한다:
val post = postDomainService.getPost(command.postId)(소속 판별 위해 로드)post.currentCommunityId?.let { communityDomainService.requireActiveMember(it, command.userId) }(FR-3 — 모임 소속이면 ACTIVE만)postDomainService.addComment(...)전역 게시글(communityId=null)은 인가 분기 미진입 → 기존 동작(FR-4).execute()≤10줄, if+throw 없음(?.let+ DomainService throw).
롤백
community 분기는 communityId null 경로에 영향 없음.
의존
- BE-25 (PostDomainService.getPost/addComment)
다이어그램
처리 흐름
sequenceDiagram participant U as AddCommentUseCase participant PDS as PostDomainService participant CDS as CommunityDomainService U->>PDS: getPost(postId) PDS-->>U: post alt post.communityId != null U->>CDS: requireActiveMember(communityId, userId) end U->>PDS: addComment(postId, userId, content)
테스트 케이스
- 전역 게시글 댓글은 인가 없이 작성된다(하위호환)
- PRIVATE 모임 ACTIVE 멤버가 댓글을 작성하면 성공한다
- PRIVATE 모임 비멤버가 댓글 작성 시 403
- PUBLIC 모임 비멤버가 댓글 작성 시 403(작성은 멤버만, FR-3)