test #339

Merged
klaus merged 4 commits from test into main 2025-09-11 17:05:45 +00:00
3 changed files with 22 additions and 15 deletions
Showing only changes of commit 27a3f450ef - Show all commits

View File

@ -66,14 +66,6 @@ class ChatCharacterController(
// 인기 캐릭터 조회
val popularCharacters = service.getPopularCharacters()
.map {
Character(
characterId = it.id!!,
name = it.name,
description = it.description,
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
)
}
// 최신 캐릭터 조회 (최대 10개)
val newCharacters = service.getNewCharacters(50)

View File

@ -1,5 +1,7 @@
package kr.co.vividnext.sodalive.chat.character.dto
import com.fasterxml.jackson.annotation.JsonProperty
data class CharacterMainResponse(
val banners: List<CharacterBannerResponse>,
val recentCharacters: List<RecentCharacter>,
@ -15,10 +17,10 @@ data class CurationSection(
)
data class Character(
val characterId: Long,
val name: String,
val description: String,
val imageUrl: String
@JsonProperty("characterId") val characterId: Long,
@JsonProperty("name") val name: String,
@JsonProperty("description") val description: String,
@JsonProperty("imageUrl") val imageUrl: String
)
data class RecentCharacter(

View File

@ -11,11 +11,13 @@ import kr.co.vividnext.sodalive.chat.character.ChatCharacterGoal
import kr.co.vividnext.sodalive.chat.character.ChatCharacterHobby
import kr.co.vividnext.sodalive.chat.character.ChatCharacterTag
import kr.co.vividnext.sodalive.chat.character.ChatCharacterValue
import kr.co.vividnext.sodalive.chat.character.dto.Character
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterGoalRepository
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterHobbyRepository
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterRepository
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterTagRepository
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterValueRepository
import org.springframework.beans.factory.annotation.Value
import org.springframework.cache.annotation.Cacheable
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service
@ -28,7 +30,10 @@ class ChatCharacterService(
private val valueRepository: ChatCharacterValueRepository,
private val hobbyRepository: ChatCharacterHobbyRepository,
private val goalRepository: ChatCharacterGoalRepository,
private val popularCharacterQuery: PopularCharacterQuery
private val popularCharacterQuery: PopularCharacterQuery,
@Value("\${cloud.aws.cloud-front.host}")
private val imageHost: String
) {
/**
* UTC 20:00 경계 기준 지난 윈도우의 메시지 상위 캐릭터 조회
@ -39,10 +44,18 @@ class ChatCharacterService(
cacheNames = ["popularCharacters_24h"],
key = "T(kr.co.vividnext.sodalive.chat.character.service.RankingWindowCalculator).now('popular-chat-character').cacheKey"
)
fun getPopularCharacters(limit: Long = 20): List<ChatCharacter> {
fun getPopularCharacters(limit: Long = 20): List<Character> {
val window = RankingWindowCalculator.now("popular-chat-character")
val topIds = popularCharacterQuery.findPopularCharacterIds(window.windowStart, window.nextBoundary, limit)
return loadCharactersInOrder(topIds)
val list = loadCharactersInOrder(topIds)
return list.map {
Character(
characterId = it.id!!,
name = it.name,
description = it.description,
imageUrl = "$imageHost/${it.imagePath ?: "profile/default-profile.png"}"
)
}
}
private fun loadCharactersInOrder(ids: List<Long>): List<ChatCharacter> {