feat(gift): 관리자 선물함 HTTP 조회를 추가한다
This commit is contained in:
+23
-1
@@ -3,12 +3,16 @@ package kr.co.vividnext.sodalive.v2.api.admin.gift.adapter.`in`.web
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftCategoryRequest
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftCategoryResponse
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftDetailResponse
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftListResponse
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftMarkUndeliverableRequest
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftOperationStatusResponse
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftSizePriceRequest
|
||||
import kr.co.vividnext.sodalive.v2.api.admin.gift.dto.AdminGiftSizePriceResponse
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.GiftAdminQueryService
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.GiftAdminService
|
||||
import kr.co.vividnext.sodalive.v2.gift.domain.GiftSize
|
||||
import kr.co.vividnext.sodalive.v2.gift.domain.GiftStatus
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
@@ -17,12 +21,30 @@ import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.PutMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v2/admin")
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
class AdminGiftController(private val service: GiftAdminService) {
|
||||
class AdminGiftController(
|
||||
private val service: GiftAdminService,
|
||||
private val queryService: GiftAdminQueryService
|
||||
) {
|
||||
@GetMapping("/gifts")
|
||||
fun getGifts(
|
||||
@RequestParam(required = false) status: GiftStatus?,
|
||||
@RequestParam(required = false) applicationNo: String?,
|
||||
@RequestParam(required = false) nickname: String?,
|
||||
@RequestParam(defaultValue = "0") page: Int,
|
||||
@RequestParam(defaultValue = "20") size: Int
|
||||
) = ApiResponse.ok(AdminGiftListResponse.from(queryService.getGifts(status, applicationNo, nickname, page, size)))
|
||||
|
||||
@GetMapping("/gifts/{applicationNo}")
|
||||
fun getGiftDetail(@PathVariable applicationNo: String) = ApiResponse.ok(
|
||||
AdminGiftDetailResponse.from(queryService.getGiftDetail(applicationNo))
|
||||
)
|
||||
|
||||
@GetMapping("/gift-categories")
|
||||
fun getCategories() = ApiResponse.ok(service.getCategories().map { AdminGiftCategoryResponse.from(it) })
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.admin.gift.dto
|
||||
|
||||
import kr.co.vividnext.sodalive.extensions.toUtcIso
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.AdminGiftDetailResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.AdminGiftInboundDeliveryInfoResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.AdminGiftListItemResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.AdminGiftListResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.AdminGiftMemberInfoResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.AdminGiftProductInfoResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.GiftCategoryResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.GiftOperationStatusResult
|
||||
import kr.co.vividnext.sodalive.v2.gift.application.GiftSizePriceResult
|
||||
@@ -63,3 +69,121 @@ data class AdminGiftOperationStatusResponse(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminGiftListResponse(
|
||||
val totalCount: Long,
|
||||
val items: List<AdminGiftListItemResponse>,
|
||||
val page: Int,
|
||||
val size: Int,
|
||||
val hasNext: Boolean
|
||||
) {
|
||||
companion object {
|
||||
fun from(result: AdminGiftListResult) = AdminGiftListResponse(
|
||||
totalCount = result.totalCount,
|
||||
items = result.items.map { AdminGiftListItemResponse.from(it) },
|
||||
page = result.page,
|
||||
size = result.size,
|
||||
hasNext = result.hasNext
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminGiftListItemResponse(
|
||||
val applicationNo: String,
|
||||
val senderNickname: String,
|
||||
val recipientNickname: String,
|
||||
val sizeCode: String,
|
||||
val sizeName: String,
|
||||
val categoryName: String,
|
||||
val classificationNumber: String,
|
||||
val courierCompanyName: String?,
|
||||
val trackingNumber: String?,
|
||||
val status: GiftStatus,
|
||||
val statusName: String,
|
||||
val availableActions: List<String>
|
||||
) {
|
||||
companion object {
|
||||
fun from(result: AdminGiftListItemResult) = AdminGiftListItemResponse(
|
||||
applicationNo = result.applicationNo,
|
||||
senderNickname = result.senderNickname,
|
||||
recipientNickname = result.recipientNickname,
|
||||
sizeCode = result.sizeCode,
|
||||
sizeName = result.sizeName,
|
||||
categoryName = result.categoryName,
|
||||
classificationNumber = result.classificationNumber,
|
||||
courierCompanyName = result.courierCompanyName,
|
||||
trackingNumber = result.trackingNumber,
|
||||
status = result.status,
|
||||
statusName = result.statusName,
|
||||
availableActions = result.availableActions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminGiftDetailResponse(
|
||||
val applicationNo: String,
|
||||
val senderInfo: AdminGiftMemberInfoResponse,
|
||||
val recipientInfo: AdminGiftMemberInfoResponse,
|
||||
val productInfo: AdminGiftProductInfoResponse,
|
||||
val inboundDeliveryInfo: AdminGiftInboundDeliveryInfoResponse,
|
||||
val status: GiftStatus,
|
||||
val statusName: String,
|
||||
val availableActions: List<String>
|
||||
) {
|
||||
companion object {
|
||||
fun from(result: AdminGiftDetailResult) = AdminGiftDetailResponse(
|
||||
applicationNo = result.applicationNo,
|
||||
senderInfo = AdminGiftMemberInfoResponse.from(result.senderInfo),
|
||||
recipientInfo = AdminGiftMemberInfoResponse.from(result.recipientInfo),
|
||||
productInfo = AdminGiftProductInfoResponse.from(result.productInfo),
|
||||
inboundDeliveryInfo = AdminGiftInboundDeliveryInfoResponse.from(result.inboundDeliveryInfo),
|
||||
status = result.status,
|
||||
statusName = result.statusName,
|
||||
availableActions = result.availableActions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminGiftMemberInfoResponse(
|
||||
val nickname: String,
|
||||
val name: String,
|
||||
val phoneNumber: String,
|
||||
val address: String
|
||||
) {
|
||||
companion object {
|
||||
fun from(result: AdminGiftMemberInfoResult) = AdminGiftMemberInfoResponse(
|
||||
nickname = result.nickname,
|
||||
name = result.name,
|
||||
phoneNumber = result.phoneNumber,
|
||||
address = result.address
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminGiftProductInfoResponse(
|
||||
val sizeCode: String,
|
||||
val sizeName: String,
|
||||
val categoryName: String,
|
||||
val classificationNumber: String
|
||||
) {
|
||||
companion object {
|
||||
fun from(result: AdminGiftProductInfoResult) = AdminGiftProductInfoResponse(
|
||||
sizeCode = result.sizeCode,
|
||||
sizeName = result.sizeName,
|
||||
categoryName = result.categoryName,
|
||||
classificationNumber = result.classificationNumber
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminGiftInboundDeliveryInfoResponse(
|
||||
val courierCompanyName: String?,
|
||||
val trackingNumber: String?
|
||||
) {
|
||||
companion object {
|
||||
fun from(result: AdminGiftInboundDeliveryInfoResult) = AdminGiftInboundDeliveryInfoResponse(
|
||||
courierCompanyName = result.courierCompanyName,
|
||||
trackingNumber = result.trackingNumber
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user