feat(community): 게시물 상세 API 엔드포인트를 추가한다

This commit is contained in:
2026-07-07 11:57:01 +09:00
parent 3bdf8353f6
commit f1072a4ce4
4 changed files with 407 additions and 0 deletions

View File

@@ -33,6 +33,53 @@ class CreatorChannelCommunityController(
)
}
@GetMapping("/community-posts/{postId}")
fun getCommunityPostDetail(
@PathVariable postId: Long,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
ApiResponse.ok(
creatorChannelCommunityFacade.getCommunityPostDetail(
postId = postId,
viewer = requireMember(member)
)
)
}
@GetMapping("/community-posts/{postId}/comments")
fun getCommunityComments(
@PathVariable postId: Long,
@RequestParam(required = false) page: Int?,
@RequestParam(required = false) size: Int?,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
ApiResponse.ok(
creatorChannelCommunityFacade.getCommunityComments(
postId = postId,
viewer = requireMember(member),
page = page,
size = size
)
)
}
@GetMapping("/community-comments/{commentId}/replies")
fun getCommunityReplies(
@PathVariable commentId: Long,
@RequestParam(required = false) page: Int?,
@RequestParam(required = false) size: Int?,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
ApiResponse.ok(
creatorChannelCommunityFacade.getCommunityReplies(
commentId = commentId,
viewer = requireMember(member),
page = page,
size = size
)
)
}
private fun requireMember(member: Member?): Member {
return member ?: throw SodaException(messageKey = "common.error.bad_credentials")
}

View File

@@ -1,6 +1,9 @@
package kr.co.vividnext.sodalive.v2.api.creator.channel.community.application
import kr.co.vividnext.sodalive.member.Member
import kr.co.vividnext.sodalive.v2.api.creator.channel.community.dto.CreatorChannelCommunityCommentsResponse
import kr.co.vividnext.sodalive.v2.api.creator.channel.community.dto.CreatorChannelCommunityPostDetailResponse
import kr.co.vividnext.sodalive.v2.api.creator.channel.community.dto.CreatorChannelCommunityRepliesResponse
import kr.co.vividnext.sodalive.v2.api.creator.channel.community.dto.CreatorChannelCommunityTabResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.application.CreatorChannelCommunityQueryService
import org.springframework.stereotype.Service
@@ -29,4 +32,54 @@ class CreatorChannelCommunityFacade(
)
)
}
fun getCommunityPostDetail(
postId: Long,
viewer: Member,
now: LocalDateTime = LocalDateTime.now()
): CreatorChannelCommunityPostDetailResponse {
return CreatorChannelCommunityPostDetailResponse.from(
creatorChannelCommunityQueryService.getCommunityPostDetail(
postId = postId,
viewer = viewer,
now = now
)
)
}
fun getCommunityComments(
postId: Long,
viewer: Member,
page: Int?,
size: Int?,
now: LocalDateTime = LocalDateTime.now()
): CreatorChannelCommunityCommentsResponse {
return CreatorChannelCommunityCommentsResponse.from(
creatorChannelCommunityQueryService.getCommunityComments(
postId = postId,
viewer = viewer,
page = page,
size = size,
now = now
)
)
}
fun getCommunityReplies(
commentId: Long,
viewer: Member,
page: Int?,
size: Int?,
now: LocalDateTime = LocalDateTime.now()
): CreatorChannelCommunityRepliesResponse {
return CreatorChannelCommunityRepliesResponse.from(
creatorChannelCommunityQueryService.getCommunityReplies(
commentId = commentId,
viewer = viewer,
page = page,
size = size,
now = now
)
)
}
}