캐릭터 챗봇 #338

Merged
klaus merged 119 commits from test into main 2025-09-10 06:08:47 +00:00
2 changed files with 7 additions and 4 deletions
Showing only changes of commit 7e7a1122fa - Show all commits

View File

@ -14,6 +14,11 @@ interface ChatCharacterRepository : JpaRepository<ChatCharacter, Long> {
fun findByName(name: String): ChatCharacter? fun findByName(name: String): ChatCharacter?
fun findByIsActiveTrue(pageable: Pageable): Page<ChatCharacter> fun findByIsActiveTrue(pageable: Pageable): Page<ChatCharacter>
/**
* 활성화된 캐릭터를 생성일 기준 내림차순으로 조회
*/
fun findByIsActiveTrueOrderByCreatedAtDesc(pageable: Pageable): List<ChatCharacter>
/** /**
* 이름, 설명, MBTI, 태그로 캐릭터 검색 * 이름, 설명, MBTI, 태그로 캐릭터 검색
*/ */

View File

@ -11,6 +11,7 @@ import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterHobbyRepo
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterRepository 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.ChatCharacterTagRepository
import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterValueRepository import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterValueRepository
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional import org.springframework.transaction.annotation.Transactional
@ -48,10 +49,7 @@ class ChatCharacterService(
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
fun getNewCharacters(limit: Int = 10): List<ChatCharacter> { fun getNewCharacters(limit: Int = 10): List<ChatCharacter> {
return chatCharacterRepository.findAll() return chatCharacterRepository.findByIsActiveTrueOrderByCreatedAtDesc(PageRequest.of(0, limit))
.filter { it.isActive }
.sortedByDescending { it.createdAt }
.take(limit)
} }
/** /**