Skip to content

Commit

Permalink
feat: #1 썸네일 칼럼 추가 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chs98412 committed Jun 15, 2024
1 parent d1a25c6 commit 4dd1444
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}
4 changes: 4 additions & 0 deletions src/main/kotlin/com/soon/common/domain/item/Item.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -29,6 +32,7 @@ class Item(
serviceNo = createModel.serviceNo,
title = createModel.title,
description = createModel.description,
thumbnail = createModel.thumbnail,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ data class ItemCreateModel(
val serviceNo: Int,
val title: String,
val description: String,
val thumbnail: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Original file line number Diff line number Diff line change
@@ -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,
)
}
}
3 changes: 2 additions & 1 deletion src/test/http/common-game.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Service-Code:eyJubyI6MSwidGl0bGUiOiJ0aXRsZSJ9

{
"title": "title",
"description": "description"
"description": "description",
"thumbnail": "thumbnail"
}

### 아이템 조회
Expand Down

0 comments on commit 4dd1444

Please sign in to comment.