-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from ClothingStoreService/test/member-delete
Test/member delete
- Loading branch information
Showing
22 changed files
with
908 additions
and
33 deletions.
There are no files selected for viewing
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
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
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/org/store/clothstar/member/service/AccountServiceImpl.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
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
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/org/store/clothstar/payment/application/PaymentServiceApplication.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,28 @@ | ||
package org.store.clothstar.payment.application | ||
|
||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import org.store.clothstar.payment.dto.request.SavePaymentRequest | ||
import org.store.clothstar.payment.service.PaymentService | ||
import org.store.clothstar.product.service.ItemService | ||
|
||
@Service | ||
class PaymentServiceApplication( | ||
private val itemService: ItemService, | ||
private val paymentService: PaymentService, | ||
) { | ||
private val log = KotlinLogging.logger {} | ||
|
||
@Transactional | ||
fun savePayment(savePaymentRequest: SavePaymentRequest) { | ||
//재고차감 | ||
log.info { "재고차감 로직 실행" } | ||
val item = itemService.getItemById(savePaymentRequest.itemId) | ||
itemService.deductItemStock(item, savePaymentRequest.buyQuantity) | ||
|
||
//구매이력 저장 | ||
log.info { "구매이력 저장 실행" } | ||
paymentService.savePayment(savePaymentRequest) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/org/store/clothstar/payment/controller/PaymentController.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,32 @@ | ||
package org.store.clothstar.payment.controller | ||
|
||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.store.clothstar.common.dto.MessageDTO | ||
import org.store.clothstar.payment.application.PaymentServiceApplication | ||
import org.store.clothstar.payment.dto.request.SavePaymentRequest | ||
|
||
@RestController | ||
class PaymentController( | ||
private val paymentServiceApplication: PaymentServiceApplication, | ||
) { | ||
private val log = KotlinLogging.logger {} | ||
|
||
@PostMapping("/v1/payments") | ||
fun savePayment(@RequestBody savePaymentRequest: SavePaymentRequest): ResponseEntity<MessageDTO> { | ||
log.info { "/v1/payment post 요청 실행" } | ||
|
||
paymentServiceApplication.savePayment(savePaymentRequest) | ||
|
||
val messageDTO = MessageDTO( | ||
HttpStatus.OK.value(), | ||
"상품을 구매 완료 하였습니다." | ||
) | ||
|
||
return ResponseEntity(messageDTO, HttpStatus.OK) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/org/store/clothstar/payment/controller/PaymentViewController.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 org.store.clothstar.payment.controller | ||
|
||
import org.springframework.stereotype.Controller | ||
import org.springframework.ui.Model | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
|
||
|
||
@Controller | ||
class PaymentViewController { | ||
@GetMapping("/payment/{productId}/{itemId}") | ||
fun paymentPage(@PathVariable itemId: Long, @PathVariable productId: Long, model: Model): String { | ||
model.addAttribute("productId", productId) | ||
model.addAttribute("itemId", itemId) | ||
return "payment" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/org/store/clothstar/payment/domain/Payment.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,28 @@ | ||
package org.store.clothstar.payment.domain | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.GeneratedValue | ||
import jakarta.persistence.GenerationType | ||
import jakarta.persistence.Id | ||
|
||
@Entity | ||
class Payment( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val paymentId: Long? = null, | ||
|
||
var productId: Long, | ||
var itemId: Long, | ||
var impUid: String, | ||
var merchantUid: String, | ||
var itemName: String, | ||
var itemOption: String, | ||
var paidAmount: Int, | ||
var buyQuantity: Int, | ||
var buyerName: String, | ||
var buyerEmail: String, | ||
var buyerTelNo: String, | ||
var buyerAddr: String, | ||
var buyerPostCode: String, | ||
) { | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/org/store/clothstar/payment/dto/request/SavePaymentRequest.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,63 @@ | ||
package org.store.clothstar.payment.dto.request | ||
|
||
import jakarta.validation.constraints.NotBlank | ||
import org.store.clothstar.payment.domain.Payment | ||
|
||
class SavePaymentRequest( | ||
@field: NotBlank | ||
var productId: Long, | ||
|
||
@field: NotBlank | ||
var itemId: Long, | ||
|
||
@field: NotBlank | ||
var impUid: String, | ||
|
||
@field: NotBlank | ||
var merchantUid: String, | ||
|
||
@field: NotBlank | ||
var itemName: String, | ||
|
||
@field: NotBlank | ||
var itemOption: String, | ||
|
||
@field: NotBlank | ||
var paidAmount: Int, | ||
|
||
@field: NotBlank | ||
var buyQuantity: Int, | ||
|
||
@field: NotBlank | ||
var buyerName: String, | ||
|
||
@field: NotBlank | ||
var buyerEmail: String, | ||
|
||
@field: NotBlank | ||
var buyerTelNo: String, | ||
|
||
@field: NotBlank | ||
var buyerAddr: String, | ||
|
||
@field: NotBlank | ||
var buyerPostCode: String, | ||
) { | ||
fun toPayment(): Payment { | ||
return Payment( | ||
productId = productId, | ||
itemId = itemId, | ||
impUid = impUid, | ||
merchantUid = merchantUid, | ||
itemName = itemName, | ||
itemOption = itemOption, | ||
paidAmount = paidAmount, | ||
buyQuantity = buyQuantity, | ||
buyerName = buyerName, | ||
buyerEmail = buyerEmail, | ||
buyerTelNo = buyerTelNo, | ||
buyerAddr = buyerAddr, | ||
buyerPostCode = buyerPostCode, | ||
) | ||
} | ||
} |
Oops, something went wrong.