캐릭터 챗봇 #338
| @@ -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, 태그로 캐릭터 검색 | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -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) |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user