diff --git a/src/main/kotlin/com/soon/common/application/model/ItemCreateCommand.kt b/src/main/kotlin/com/soon/common/application/model/ItemCreateCommand.kt index ec4d42a..dafd596 100644 --- a/src/main/kotlin/com/soon/common/application/model/ItemCreateCommand.kt +++ b/src/main/kotlin/com/soon/common/application/model/ItemCreateCommand.kt @@ -6,10 +6,12 @@ data class ItemCreateCommand( val serviceNo: Int, val title: String, val description: String, + val thumbnail: String, ) { fun toCreateModel() = ItemCreateModel( serviceNo = serviceNo, title = title, description = description, + thumbnail = thumbnail, ) } \ No newline at end of file diff --git a/src/main/kotlin/com/soon/common/application/model/ItemGetSummary.kt b/src/main/kotlin/com/soon/common/application/model/ItemGetSummary.kt index 9e2864c..1de31ec 100644 --- a/src/main/kotlin/com/soon/common/application/model/ItemGetSummary.kt +++ b/src/main/kotlin/com/soon/common/application/model/ItemGetSummary.kt @@ -3,15 +3,19 @@ package com.soon.common.application.model import com.soon.common.domain.item.Item data class ItemGetSummary( + val itemNo: Int, val serviceNo: Int, val title: String, val description: String, + val thumbnail: String, ) { companion object { fun of(item: Item) = ItemGetSummary( + itemNo = item.no, serviceNo = item.serviceNo, title = item.title, description = item.description, + thumbnail = item.thumbnail, ) } } diff --git a/src/main/kotlin/com/soon/common/domain/item/Item.kt b/src/main/kotlin/com/soon/common/domain/item/Item.kt index a00a5ae..c7cf4ea 100644 --- a/src/main/kotlin/com/soon/common/domain/item/Item.kt +++ b/src/main/kotlin/com/soon/common/domain/item/Item.kt @@ -20,6 +20,9 @@ class Item( @Column(name = "description") val description: String, + + @Column(name = "thumbnail") + val thumbnail: String, ) { @Column(name = "created_at") val createdAt: LocalDateTime = LocalDateTime.now() @@ -29,6 +32,7 @@ class Item( serviceNo = createModel.serviceNo, title = createModel.title, description = createModel.description, + thumbnail = createModel.thumbnail, ) } } \ No newline at end of file diff --git a/src/main/kotlin/com/soon/common/domain/item/model/ItemCreateModel.kt b/src/main/kotlin/com/soon/common/domain/item/model/ItemCreateModel.kt index d8a4a1b..6a4b932 100644 --- a/src/main/kotlin/com/soon/common/domain/item/model/ItemCreateModel.kt +++ b/src/main/kotlin/com/soon/common/domain/item/model/ItemCreateModel.kt @@ -4,4 +4,5 @@ data class ItemCreateModel( val serviceNo: Int, val title: String, val description: String, + val thumbnail: String, ) diff --git a/src/main/kotlin/com/soon/common/presentation/handler/ItemHandler.kt b/src/main/kotlin/com/soon/common/presentation/handler/ItemHandler.kt index 0a2bd53..f66a443 100644 --- a/src/main/kotlin/com/soon/common/presentation/handler/ItemHandler.kt +++ b/src/main/kotlin/com/soon/common/presentation/handler/ItemHandler.kt @@ -6,6 +6,7 @@ import com.soon.common.application.util.coroutines.ApplicationDispatchers import com.soon.common.presentation.extension.extractServiceCodeHeader import com.soon.common.presentation.extension.intQueryParam import com.soon.common.presentation.handler.model.ItemCreateRequest +import com.soon.common.presentation.handler.model.ItemGetResponse import kotlinx.coroutines.withContext import org.springframework.stereotype.Service import org.springframework.web.reactive.function.server.* @@ -26,6 +27,7 @@ class ItemHandler( suspend fun getItem(request: ServerRequest): ServerResponse = withContext(ApplicationDispatchers.IO) { val itemNo = request.intQueryParam("itemNo") - ServerResponse.ok().bodyValueAndAwait(itemQueryService.getItem(itemNo)) + val summary = itemQueryService.getItem(itemNo) + ServerResponse.ok().bodyValueAndAwait(ItemGetResponse.of(summary)) } } \ No newline at end of file diff --git a/src/main/kotlin/com/soon/common/presentation/handler/model/ItemCreateRequest.kt b/src/main/kotlin/com/soon/common/presentation/handler/model/ItemCreateRequest.kt index 2e01d12..0e18940 100644 --- a/src/main/kotlin/com/soon/common/presentation/handler/model/ItemCreateRequest.kt +++ b/src/main/kotlin/com/soon/common/presentation/handler/model/ItemCreateRequest.kt @@ -5,10 +5,12 @@ import com.soon.common.application.model.ItemCreateCommand data class ItemCreateRequest( val title: String, val description: String, + val thumbnail: String, ) { fun toCommand(serviceNo: Int) = ItemCreateCommand( serviceNo = serviceNo, title = title, description = description, + thumbnail = thumbnail, ) } diff --git a/src/main/kotlin/com/soon/common/presentation/handler/model/ItemGetResponse.kt b/src/main/kotlin/com/soon/common/presentation/handler/model/ItemGetResponse.kt new file mode 100644 index 0000000..8665362 --- /dev/null +++ b/src/main/kotlin/com/soon/common/presentation/handler/model/ItemGetResponse.kt @@ -0,0 +1,21 @@ +package com.soon.common.presentation.handler.model + +import com.soon.common.application.model.ItemGetSummary + +data class ItemGetResponse( + val itemNo: Int, + val serviceNo: Int, + val title: String, + val description: String, + val thumbnail: String, +) { + companion object { + fun of(summary: ItemGetSummary) = ItemGetResponse( + itemNo = summary.itemNo, + serviceNo = summary.serviceNo, + title = summary.title, + description = summary.description, + thumbnail = summary.thumbnail, + ) + } +} diff --git a/src/test/http/common-game.http b/src/test/http/common-game.http index 067d532..b335287 100644 --- a/src/test/http/common-game.http +++ b/src/test/http/common-game.http @@ -5,7 +5,8 @@ Service-Code:eyJubyI6MSwidGl0bGUiOiJ0aXRsZSJ9 { "title": "title", - "description": "description" + "description": "description", + "thumbnail": "thumbnail" } ### 아이템 조회