generated from pricelees/issue-pr-template
[#50] Tosspay API Mocking 서버 구현 #51
@ -0,0 +1,24 @@
|
|||||||
|
package com.sangdol.tosspaymock.infrastructure.persistence
|
||||||
|
|
||||||
|
import com.sangdol.common.persistence.PersistableBaseEntity
|
||||||
|
import jakarta.persistence.Column
|
||||||
|
import jakarta.persistence.Entity
|
||||||
|
import jakarta.persistence.Table
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "order_amount")
|
||||||
|
class OrderAmountEntity(
|
||||||
|
id: Long,
|
||||||
|
|
||||||
|
@Column(unique = true)
|
||||||
|
val paymentKey: String,
|
||||||
|
|
||||||
|
val approvedAmount: Int,
|
||||||
|
val easypayDiscountAmount: Int,
|
||||||
|
val cardDiscountAmount: Int,
|
||||||
|
val transferDiscountAmount: Int
|
||||||
|
) : PersistableBaseEntity(id) {
|
||||||
|
fun totalAmount(): Int {
|
||||||
|
return (approvedAmount + easypayDiscountAmount + cardDiscountAmount + transferDiscountAmount)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.sangdol.tosspaymock.infrastructure.persistence
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
|
||||||
|
interface OrderAmountRepository : JpaRepository<OrderAmountEntity, Long> {
|
||||||
|
|
||||||
|
fun findByPaymentKey(paymentKey: String): OrderAmountEntity?
|
||||||
|
}
|
||||||
10
tosspay-mock/src/main/resources/schema/schema-h2.sql
Normal file
10
tosspay-mock/src/main/resources/schema/schema-h2.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
create table if not exists order_amount (
|
||||||
|
id bigint primary key,
|
||||||
|
payment_key varchar(255) not null,
|
||||||
|
approved_amount integer not null,
|
||||||
|
easypay_discount_amount integer not null,
|
||||||
|
card_discount_amount integer not null,
|
||||||
|
transfer_discount_amount integer not null,
|
||||||
|
|
||||||
|
constraint uk_order_amount__payment_key unique (payment_key)
|
||||||
|
);
|
||||||
Loading…
x
Reference in New Issue
Block a user