generated from pricelees/issue-pr-template
refactor: payment 도메인 내 Entity & Repository 재정의 및 V2 접미사 제거
This commit is contained in:
parent
6d8b85a9e3
commit
6c093aeb39
@ -1,33 +1,24 @@
|
|||||||
package roomescape.payment.infrastructure.persistence
|
package roomescape.payment.infrastructure.persistence
|
||||||
|
|
||||||
import jakarta.persistence.Column
|
|
||||||
import jakarta.persistence.Entity
|
import jakarta.persistence.Entity
|
||||||
import jakarta.persistence.Id
|
|
||||||
import jakarta.persistence.Table
|
import jakarta.persistence.Table
|
||||||
import roomescape.common.entity.BaseEntity
|
import roomescape.common.entity.PersistableBaseEntity
|
||||||
|
import java.time.LocalDateTime
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "canceled_payments")
|
@Table(name = "canceled_payment")
|
||||||
class CanceledPaymentEntity(
|
class CanceledPaymentEntity(
|
||||||
@Id
|
id: Long,
|
||||||
@Column(name = "canceled_payment_id")
|
|
||||||
private var _id: Long?,
|
|
||||||
|
|
||||||
@Column(name = "payment_key", nullable = false)
|
val paymentId: Long,
|
||||||
var paymentKey: String,
|
val requestedAt: LocalDateTime,
|
||||||
|
val canceledAt: OffsetDateTime,
|
||||||
|
val canceledBy: Long,
|
||||||
|
val cancelReason: String,
|
||||||
|
val cancelAmount: Int,
|
||||||
|
val cardDiscountAmount: Int,
|
||||||
|
val transferDiscountAmount: Int,
|
||||||
|
val easypayDiscountAmount: Int,
|
||||||
|
) : PersistableBaseEntity(id)
|
||||||
|
|
||||||
@Column(name = "cancel_reason", nullable = false)
|
|
||||||
var cancelReason: String,
|
|
||||||
|
|
||||||
@Column(name = "cancel_amount", nullable = false)
|
|
||||||
var cancelAmount: Long,
|
|
||||||
|
|
||||||
@Column(name = "approved_at", nullable = false)
|
|
||||||
var approvedAt: OffsetDateTime,
|
|
||||||
|
|
||||||
@Column(name = "canceled_at", nullable = false)
|
|
||||||
var canceledAt: OffsetDateTime,
|
|
||||||
): BaseEntity() {
|
|
||||||
override fun getId(): Long? = _id
|
|
||||||
}
|
|
||||||
|
|||||||
@ -3,5 +3,5 @@ package roomescape.payment.infrastructure.persistence
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
|
||||||
interface CanceledPaymentRepository : JpaRepository<CanceledPaymentEntity, Long> {
|
interface CanceledPaymentRepository : JpaRepository<CanceledPaymentEntity, Long> {
|
||||||
fun findByPaymentKey(paymentKey: String): CanceledPaymentEntity?
|
fun findByPaymentId(paymentId: Long): CanceledPaymentEntity?
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
package roomescape.payment.infrastructure.persistence.v2
|
package roomescape.payment.infrastructure.persistence
|
||||||
|
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
import roomescape.common.entity.PersistableBaseEntity
|
import roomescape.common.entity.PersistableBaseEntity
|
||||||
import roomescape.payment.infrastructure.common.*
|
import roomescape.payment.infrastructure.common.*
|
||||||
import kotlin.jvm.Transient
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "payment_detail")
|
@Table(name = "payment_detail")
|
||||||
@ -14,9 +13,6 @@ open class PaymentDetailEntity(
|
|||||||
open val paymentId: Long,
|
open val paymentId: Long,
|
||||||
open val suppliedAmount: Int,
|
open val suppliedAmount: Int,
|
||||||
open val vat: Int,
|
open val vat: Int,
|
||||||
|
|
||||||
@Transient
|
|
||||||
private var isNewEntity: Boolean = true
|
|
||||||
) : PersistableBaseEntity(id)
|
) : PersistableBaseEntity(id)
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package roomescape.payment.infrastructure.persistence.v2
|
package roomescape.payment.infrastructure.persistence
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
|
||||||
@ -1,32 +1,38 @@
|
|||||||
package roomescape.payment.infrastructure.persistence
|
package roomescape.payment.infrastructure.persistence
|
||||||
|
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.Entity
|
||||||
import roomescape.common.entity.BaseEntity
|
import jakarta.persistence.EnumType
|
||||||
import roomescape.reservation.infrastructure.persistence.ReservationEntity
|
import jakarta.persistence.Enumerated
|
||||||
|
import jakarta.persistence.Table
|
||||||
|
import roomescape.common.entity.PersistableBaseEntity
|
||||||
|
import roomescape.payment.infrastructure.common.PaymentMethod
|
||||||
|
import roomescape.payment.infrastructure.common.PaymentStatus
|
||||||
|
import roomescape.payment.infrastructure.common.PaymentType
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "payments")
|
@Table(name = "payment")
|
||||||
class PaymentEntity(
|
class PaymentEntity(
|
||||||
@Id
|
id: Long,
|
||||||
@Column(name = "payment_id")
|
|
||||||
private var _id: Long?,
|
|
||||||
|
|
||||||
@Column(name = "order_id", nullable = false)
|
val reservationId: Long,
|
||||||
var orderId: String,
|
val paymentKey: String,
|
||||||
|
val orderId: String,
|
||||||
|
val totalAmount: Int,
|
||||||
|
val requestedAt: OffsetDateTime,
|
||||||
|
val approvedAt: OffsetDateTime,
|
||||||
|
|
||||||
@Column(name="payment_key", nullable = false)
|
@Enumerated(EnumType.STRING)
|
||||||
var paymentKey: String,
|
val type: PaymentType,
|
||||||
|
|
||||||
@Column(name="total_amount", nullable = false)
|
@Enumerated(EnumType.STRING)
|
||||||
var totalAmount: Long,
|
val method: PaymentMethod,
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@Enumerated(EnumType.STRING)
|
||||||
@JoinColumn(name = "reservation_id", nullable = false)
|
var status: PaymentStatus
|
||||||
var reservation: ReservationEntity,
|
) : PersistableBaseEntity(id) {
|
||||||
|
|
||||||
@Column(name="approved_at", nullable = false)
|
fun cancel() {
|
||||||
var approvedAt: OffsetDateTime
|
this.status = PaymentStatus.CANCELED
|
||||||
): BaseEntity() {
|
}
|
||||||
override fun getId(): Long? = _id
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,9 +4,5 @@ import org.springframework.data.jpa.repository.JpaRepository
|
|||||||
|
|
||||||
interface PaymentRepository : JpaRepository<PaymentEntity, Long> {
|
interface PaymentRepository : JpaRepository<PaymentEntity, Long> {
|
||||||
|
|
||||||
fun existsByReservationId(reservationId: Long): Boolean
|
|
||||||
|
|
||||||
fun findByReservationId(reservationId: Long): PaymentEntity?
|
fun findByReservationId(reservationId: Long): PaymentEntity?
|
||||||
|
|
||||||
fun deleteByPaymentKey(paymentKey: String)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package roomescape.reservation_v2.infrastructure.persistence
|
package roomescape.reservation.infrastructure.persistence
|
||||||
|
|
||||||
import jakarta.persistence.Entity
|
import jakarta.persistence.Entity
|
||||||
import jakarta.persistence.EnumType
|
import jakarta.persistence.EnumType
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package roomescape.reservation_v2.infrastructure.persistence
|
package roomescape.reservation.infrastructure.persistence
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user