feat(home): 인기 커뮤니티 게시글 응답 필드를 추가한다

This commit is contained in:
2026-06-01 22:40:29 +09:00
parent 12b446c4ae
commit 5d606a257e
3 changed files with 35 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ import kr.co.vividnext.sodalive.v2.api.home.dto.HomeCreatorItem
import kr.co.vividnext.sodalive.v2.api.home.dto.HomeFirstAudioContentItem import kr.co.vividnext.sodalive.v2.api.home.dto.HomeFirstAudioContentItem
import kr.co.vividnext.sodalive.v2.api.home.dto.HomeGenreCreatorGroupItem import kr.co.vividnext.sodalive.v2.api.home.dto.HomeGenreCreatorGroupItem
import kr.co.vividnext.sodalive.v2.api.home.dto.HomeLiveItem import kr.co.vividnext.sodalive.v2.api.home.dto.HomeLiveItem
import kr.co.vividnext.sodalive.v2.api.home.dto.HomePopularCommunityItem import kr.co.vividnext.sodalive.v2.api.home.dto.HomePopularCommunityPostItem
import kr.co.vividnext.sodalive.v2.api.home.dto.HomeRecommendationPageResponse import kr.co.vividnext.sodalive.v2.api.home.dto.HomeRecommendationPageResponse
import kr.co.vividnext.sodalive.v2.api.home.dto.HomeRecommendationResponse import kr.co.vividnext.sodalive.v2.api.home.dto.HomeRecommendationResponse
import kr.co.vividnext.sodalive.v2.api.home.dto.imageUrl import kr.co.vividnext.sodalive.v2.api.home.dto.imageUrl
@@ -81,7 +81,7 @@ class HomeRecommendationFacade(
).map { it.toItem() }, ).map { it.toItem() },
cheerCreators = queryService.findCheerCreatorRecommendations(HOME_CHEER_CREATOR_LIMIT, member?.id) cheerCreators = queryService.findCheerCreatorRecommendations(HOME_CHEER_CREATOR_LIMIT, member?.id)
.map { it.toCreatorItem() }, .map { it.toCreatorItem() },
popularCommunities = queryService.findPopularCommunityRecommendations( popularCommunityPosts = queryService.findPopularCommunityRecommendations(
limit = HOME_POPULAR_COMMUNITY_LIMIT, limit = HOME_POPULAR_COMMUNITY_LIMIT,
memberId = member?.id, memberId = member?.id,
includeAdultCommunities = includeAdult includeAdultCommunities = includeAdult
@@ -205,7 +205,7 @@ class HomeRecommendationFacade(
if (aiCharacters.isEmpty()) add("aiCharacters") if (aiCharacters.isEmpty()) add("aiCharacters")
if (genreCreators.isEmpty()) add("genreCreators") if (genreCreators.isEmpty()) add("genreCreators")
if (cheerCreators.isEmpty()) add("cheerCreators") if (cheerCreators.isEmpty()) add("cheerCreators")
if (popularCommunities.isEmpty()) add("popularCommunities") if (popularCommunityPosts.isEmpty()) add("popularCommunityPosts")
} }
} }
@@ -301,15 +301,18 @@ class HomeRecommendationFacade(
creatorProfileImage = imageUrl(cloudFrontHost, creatorProfileImage) creatorProfileImage = imageUrl(cloudFrontHost, creatorProfileImage)
) )
private fun HomePopularCommunityRecommendationRecord.toItem() = HomePopularCommunityItem( private fun HomePopularCommunityRecommendationRecord.toItem() = HomePopularCommunityPostItem(
communityId = communityId, postId = communityId,
creatorId = creatorId, creatorId = creatorId,
creatorNickname = creatorNickname, creatorNickname = creatorNickname,
creatorProfileImage = imageUrl(cloudFrontHost, creatorProfileImage), creatorProfileImage = imageUrl(cloudFrontHost, creatorProfileImage),
imageUrl = imageUrl(cloudFrontHost, imagePath),
audioUrl = imageUrl(cloudFrontHost, audioPath),
content = content, content = content,
createdAt = createdAt.toUtcIso(), createdAt = createdAt.toUtcIso(),
likeCount = likeCount, likeCount = likeCount,
commentCount = commentCount commentCount = commentCount,
existOrdered = existOrdered
) )
companion object { companion object {

View File

@@ -21,7 +21,7 @@ data class HomeRecommendationResponse(
val aiCharacters: List<HomeAiCharacterItem>, val aiCharacters: List<HomeAiCharacterItem>,
val genreCreators: List<HomeGenreCreatorGroupItem>, val genreCreators: List<HomeGenreCreatorGroupItem>,
val cheerCreators: List<HomeCreatorItem>, val cheerCreators: List<HomeCreatorItem>,
val popularCommunities: List<HomePopularCommunityItem> val popularCommunityPosts: List<HomePopularCommunityPostItem>
) )
data class HomeLiveItem( data class HomeLiveItem(
@@ -87,13 +87,16 @@ data class HomeGenreCreatorGroupItem(
val creators: List<HomeCreatorItem> val creators: List<HomeCreatorItem>
) )
data class HomePopularCommunityItem( data class HomePopularCommunityPostItem(
val communityId: Long, val postId: Long,
val creatorId: Long, val creatorId: Long,
val creatorNickname: String, val creatorNickname: String,
val creatorProfileImage: String?, val creatorProfileImage: String?,
val imageUrl: String?,
val audioUrl: String?,
val content: String, val content: String,
val createdAt: String, val createdAt: String,
val likeCount: Long, val likeCount: Long,
val commentCount: Long val commentCount: Long,
val existOrdered: Boolean
) )

View File

@@ -39,7 +39,21 @@ class HomeRecommendationResponseTest {
), ),
genreCreators = emptyList(), genreCreators = emptyList(),
cheerCreators = emptyList(), cheerCreators = emptyList(),
popularCommunities = emptyList() popularCommunityPosts = listOf(
HomePopularCommunityPostItem(
postId = 5L,
creatorId = 6L,
creatorNickname = "community-creator",
creatorProfileImage = "https://cdn.test/profile/community.png",
imageUrl = "https://cdn.test/community/image.png",
audioUrl = "https://cdn.test/community/audio.mp3",
content = "community content",
createdAt = "2026-06-01T00:00:00Z",
likeCount = 7L,
commentCount = 8L,
existOrdered = true
)
)
) )
val json = objectMapper.readTree(objectMapper.writeValueAsString(response)) val json = objectMapper.readTree(objectMapper.writeValueAsString(response))
@@ -47,5 +61,9 @@ class HomeRecommendationResponseTest {
assertEquals(true, json["firstAudioContents"][0]["isPointAvailable"].asBoolean()) assertEquals(true, json["firstAudioContents"][0]["isPointAvailable"].asBoolean())
assertFalse(json["firstAudioContents"][0].has("pointAvailable")) assertFalse(json["firstAudioContents"][0].has("pointAvailable"))
assertEquals("https://cdn.test/profile/character.png", json["aiCharacters"][0]["profileImage"].asText()) assertEquals("https://cdn.test/profile/character.png", json["aiCharacters"][0]["profileImage"].asText())
assertEquals(5L, json["popularCommunityPosts"][0]["postId"].asLong())
assertEquals("https://cdn.test/community/image.png", json["popularCommunityPosts"][0]["imageUrl"].asText())
assertEquals("https://cdn.test/community/audio.mp3", json["popularCommunityPosts"][0]["audioUrl"].asText())
assertEquals(true, json["popularCommunityPosts"][0]["existOrdered"].asBoolean())
} }
} }