캐릭터 챗봇 #338
| @@ -1,6 +1,7 @@ | |||||||
| package kr.co.vividnext.sodalive.admin.chat | package kr.co.vividnext.sodalive.admin.chat | ||||||
|  |  | ||||||
| import com.amazonaws.services.s3.model.ObjectMetadata | import com.amazonaws.services.s3.model.ObjectMetadata | ||||||
|  | import kr.co.vividnext.sodalive.admin.chat.character.dto.ChatCharacterSearchListPageResponse | ||||||
| import kr.co.vividnext.sodalive.admin.chat.character.service.AdminChatCharacterService | import kr.co.vividnext.sodalive.admin.chat.character.service.AdminChatCharacterService | ||||||
| import kr.co.vividnext.sodalive.admin.chat.dto.ChatCharacterBannerListPageResponse | import kr.co.vividnext.sodalive.admin.chat.dto.ChatCharacterBannerListPageResponse | ||||||
| import kr.co.vividnext.sodalive.admin.chat.dto.ChatCharacterBannerRegisterRequest | import kr.co.vividnext.sodalive.admin.chat.dto.ChatCharacterBannerRegisterRequest | ||||||
| @@ -27,7 +28,7 @@ import org.springframework.web.bind.annotation.RestController | |||||||
| import org.springframework.web.multipart.MultipartFile | import org.springframework.web.multipart.MultipartFile | ||||||
|  |  | ||||||
| @RestController | @RestController | ||||||
| @RequestMapping("/api/admin/chat/banner") | @RequestMapping("/admin/chat/banner") | ||||||
| @PreAuthorize("hasRole('ADMIN')") | @PreAuthorize("hasRole('ADMIN')") | ||||||
| class AdminChatBannerController( | class AdminChatBannerController( | ||||||
|     private val bannerService: ChatCharacterBannerService, |     private val bannerService: ChatCharacterBannerService, | ||||||
| @@ -91,7 +92,11 @@ class AdminChatBannerController( | |||||||
|         @RequestParam(defaultValue = "20") size: Int |         @RequestParam(defaultValue = "20") size: Int | ||||||
|     ) = run { |     ) = run { | ||||||
|         val pageable = adminCharacterService.createDefaultPageRequest(page, size) |         val pageable = adminCharacterService.createDefaultPageRequest(page, size) | ||||||
|         val response = adminCharacterService.searchCharacters(searchTerm, pageable, imageHost) |         val pageResult = adminCharacterService.searchCharacters(searchTerm, pageable, imageHost) | ||||||
|  |         val response = ChatCharacterSearchListPageResponse( | ||||||
|  |             totalCount = pageResult.totalElements, | ||||||
|  |             content = pageResult.content | ||||||
|  |         ) | ||||||
|  |  | ||||||
|         ApiResponse.ok(response) |         ApiResponse.ok(response) | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -8,23 +8,23 @@ import kr.co.vividnext.sodalive.chat.character.ChatCharacter | |||||||
| data class ChatCharacterSearchResponse( | data class ChatCharacterSearchResponse( | ||||||
|     val id: Long, |     val id: Long, | ||||||
|     val name: String, |     val name: String, | ||||||
|     val description: String, |     val imagePath: String? | ||||||
|     val mbti: String?, |  | ||||||
|     val imagePath: String?, |  | ||||||
|     val tags: List<String> |  | ||||||
| ) { | ) { | ||||||
|     companion object { |     companion object { | ||||||
|         fun from(character: ChatCharacter, imageHost: String): ChatCharacterSearchResponse { |         fun from(character: ChatCharacter, imageHost: String): ChatCharacterSearchResponse { | ||||||
|             val tags = character.tagMappings.map { it.tag.tag } |  | ||||||
|  |  | ||||||
|             return ChatCharacterSearchResponse( |             return ChatCharacterSearchResponse( | ||||||
|                 id = character.id!!, |                 id = character.id!!, | ||||||
|                 name = character.name, |                 name = character.name, | ||||||
|                 description = character.description, |                 imagePath = character.imagePath?.let { "$imageHost/$it" } | ||||||
|                 mbti = character.mbti, |  | ||||||
|                 imagePath = character.imagePath?.let { "$imageHost/$it" }, |  | ||||||
|                 tags = tags |  | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 캐릭터 검색 결과 페이지 응답 DTO | ||||||
|  |  */ | ||||||
|  | data class ChatCharacterSearchListPageResponse( | ||||||
|  |     val totalCount: Long, | ||||||
|  |     val content: List<ChatCharacterSearchResponse> | ||||||
|  | ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user