캐릭터 챗봇 #338
| @@ -14,6 +14,11 @@ interface ChatCharacterRepository : JpaRepository<ChatCharacter, Long> { | ||||
|     fun findByName(name: String): ChatCharacter? | ||||
|     fun findByIsActiveTrue(pageable: Pageable): Page<ChatCharacter> | ||||
|  | ||||
|     /** | ||||
|      * 활성화된 캐릭터를 생성일 기준 내림차순으로 조회 | ||||
|      */ | ||||
|     fun findByIsActiveTrueOrderByCreatedAtDesc(pageable: Pageable): List<ChatCharacter> | ||||
|  | ||||
|     /** | ||||
|      * 이름, 설명, MBTI, 태그로 캐릭터 검색 | ||||
|      */ | ||||
|   | ||||
| @@ -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.ChatCharacterTagRepository | ||||
| import kr.co.vividnext.sodalive.chat.character.repository.ChatCharacterValueRepository | ||||
| import org.springframework.data.domain.PageRequest | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
|  | ||||
| @@ -48,10 +49,7 @@ class ChatCharacterService( | ||||
|      */ | ||||
|     @Transactional(readOnly = true) | ||||
|     fun getNewCharacters(limit: Int = 10): List<ChatCharacter> { | ||||
|         return chatCharacterRepository.findAll() | ||||
|             .filter { it.isActive } | ||||
|             .sortedByDescending { it.createdAt } | ||||
|             .take(limit) | ||||
|         return chatCharacterRepository.findByIsActiveTrueOrderByCreatedAtDesc(PageRequest.of(0, limit)) | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user