-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
74 additions
and
25 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/soon/common/application/ItemQueryService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.soon.common.application | ||
|
||
import com.soon.common.application.model.ItemGetSummary | ||
import com.soon.common.domain.item.ItemRepository | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class ItemQueryService( | ||
private val itemRepository: ItemRepository, | ||
) { | ||
fun getItem(itemNo: Int): ItemGetSummary { | ||
return itemRepository.findByIdOrNull(itemNo)?.let { | ||
ItemGetSummary.of(it) | ||
} ?: throw IllegalArgumentException() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/soon/common/application/model/ItemGetSummary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.soon.common.application.model | ||
|
||
import com.soon.common.domain.item.Item | ||
|
||
data class ItemGetSummary( | ||
val serviceNo: Int, | ||
val title: String, | ||
val description: String, | ||
) { | ||
companion object { | ||
fun of(item: Item) = ItemGetSummary( | ||
serviceNo = item.serviceNo, | ||
title = item.title, | ||
description = item.description, | ||
) | ||
} | ||
} |
14 changes: 7 additions & 7 deletions
14
src/main/kotlin/com/soon/common/presentation/extension/MemberHeader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.soon.member.presentation.extension | ||
package com.soon.common.presentation.extension | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
|
||
data class MemberHeader | ||
( | ||
@JsonProperty("no") | ||
val no: Int, | ||
@JsonProperty("name") | ||
val name: String, | ||
@JsonProperty("account") | ||
val account: String, | ||
@JsonProperty("no") | ||
val no: Int, | ||
@JsonProperty("name") | ||
val name: String, | ||
@JsonProperty("account") | ||
val account: String, | ||
) |
27 changes: 16 additions & 11 deletions
27
src/main/kotlin/com/soon/common/presentation/extension/RequestExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
package com.soon.member.presentation.extension | ||
package com.soon.common.presentation.extension | ||
|
||
import com.soon.common.domain.extension.decodeBase64ToDto | ||
import com.soon.common.presentation.extension.ServiceHeader | ||
import org.springframework.web.reactive.function.server.ServerRequest | ||
import org.springframework.web.reactive.function.server.queryParamOrNull | ||
|
||
fun ServerRequest.extractMemberCodeHeader() :MemberHeader{ | ||
fun ServerRequest.extractMemberCodeHeader(): MemberHeader { | ||
return headers().header("Member-Code").firstOrNull() | ||
?.let{ | ||
it.decodeBase64ToDto<MemberHeader>() | ||
}?:throw IllegalArgumentException() | ||
?.let { | ||
it.decodeBase64ToDto<MemberHeader>() | ||
} ?: throw IllegalArgumentException() | ||
} | ||
|
||
fun ServerRequest.extractServiceCodeHeader() :ServiceHeader{ | ||
fun ServerRequest.extractServiceCodeHeader(): ServiceHeader { | ||
return headers().header("Service-Code").firstOrNull() | ||
?.let{ | ||
it.decodeBase64ToDto<ServiceHeader>() | ||
}?:throw IllegalArgumentException() | ||
} | ||
?.let { | ||
it.decodeBase64ToDto<ServiceHeader>() | ||
} ?: throw IllegalArgumentException() | ||
} | ||
|
||
fun ServerRequest.intQueryParam(parameter: String): Int { | ||
return queryParamOrNull(parameter)?.toIntOrNull() | ||
?: throw IllegalArgumentException("Invalid or missing 'itemNo' query parameter") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
### 아이템 생성 | ||
POST localhost:8083/common/backoffice/item | ||
POST localhost:8083/internal/common/item | ||
Content-Type: application/json | ||
Service-Code:eyJubyI6MSwidGl0bGUiOiJ0aXRsZSJ9 | ||
|
||
{ | ||
"title": "title", | ||
"description": "description" | ||
} | ||
|
||
### 아이템 조회 | ||
GET localhost:8083/internal/common/item?itemNo=1 | ||
Content-Type: application/json | ||
Service-Code:eyJubyI6MSwidGl0bGUiOiJ0aXRsZSJ9 |