feat(admin-character-list): 캐릭터 검색에 페이징 추가
This commit is contained in:
@@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.admin.chat.character
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import kr.co.vividnext.sodalive.admin.chat.character.dto.ChatCharacterRegisterRequest
|
||||
import kr.co.vividnext.sodalive.admin.chat.character.dto.ChatCharacterSearchListPageResponse
|
||||
import kr.co.vividnext.sodalive.admin.chat.character.dto.ChatCharacterUpdateRequest
|
||||
import kr.co.vividnext.sodalive.admin.chat.character.dto.ExternalApiResponse
|
||||
import kr.co.vividnext.sodalive.admin.chat.character.service.AdminChatCharacterService
|
||||
@@ -73,14 +74,21 @@ class AdminChatCharacterController(
|
||||
/**
|
||||
* 캐릭터 검색(관리자)
|
||||
* - 이름/설명/MBTI/태그 기준 부분 검색, 활성 캐릭터만 대상
|
||||
* - 페이징 제거: 전체 목록 반환
|
||||
* - 페이징 지원: page, size 파라미터 사용
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
fun searchCharacters(
|
||||
@RequestParam("searchTerm") searchTerm: String
|
||||
@RequestParam("searchTerm") searchTerm: String,
|
||||
@RequestParam(defaultValue = "0") page: Int,
|
||||
@RequestParam(defaultValue = "20") size: Int
|
||||
) = run {
|
||||
val list = adminService.searchCharactersAll(searchTerm, imageHost)
|
||||
ApiResponse.ok(list)
|
||||
val pageable = adminService.createDefaultPageRequest(page, size)
|
||||
val resultPage = adminService.searchCharacters(searchTerm, pageable, imageHost)
|
||||
val response = ChatCharacterSearchListPageResponse(
|
||||
totalCount = resultPage.totalElements,
|
||||
content = resultPage.content
|
||||
)
|
||||
ApiResponse.ok(response)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,20 +76,4 @@ class AdminChatCharacterService(
|
||||
val characters = chatCharacterRepository.searchCharacters(searchTerm, pageable)
|
||||
return characters.map { ChatCharacterSearchResponse.from(it, imageHost) }
|
||||
}
|
||||
|
||||
/**
|
||||
* 캐릭터 검색 (이름, 설명, MBTI, 태그 기반) - 무페이징
|
||||
*
|
||||
* @param searchTerm 검색어
|
||||
* @param imageHost 이미지 호스트 URL
|
||||
* @return 검색된 캐릭터 목록 (전체)
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
fun searchCharactersAll(
|
||||
searchTerm: String,
|
||||
imageHost: String = ""
|
||||
): List<ChatCharacterSearchResponse> {
|
||||
val characters = chatCharacterRepository.searchCharactersNoPaging(searchTerm)
|
||||
return characters.map { ChatCharacterSearchResponse.from(it, imageHost) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user