feat: order 서비스에서 사용할 재시도 & 후처리를 위한 테이블 추가

This commit is contained in:
이상진 2025-10-07 22:20:18 +09:00
parent 365a2a37ae
commit e6040fcd44
4 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package com.sangdol.roomescape.order.infrastructure.persistence
import com.sangdol.common.persistence.PersistableBaseEntity
import jakarta.persistence.*
import org.springframework.data.annotation.CreatedBy
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.time.Instant
@Entity
@EntityListeners(AuditingEntityListener::class)
@Table(name = "payment_attempts")
class PaymentAttemptEntity(
id: Long,
val reservationId: Long,
@Enumerated(value = EnumType.STRING)
val result: AttemptResult,
@Column(columnDefinition = "VARCHAR(50)")
val errorCode: String? = null,
@Column(columnDefinition = "TEXT")
val message: String? = null,
) : PersistableBaseEntity(id) {
@Column(updatable = false)
@CreatedDate
lateinit var createdAt: Instant
@Column(updatable = false)
@CreatedBy
var createdBy: Long = 0L
}
enum class AttemptResult {
SUCCESS, FAILED
}

View File

@ -0,0 +1,16 @@
package com.sangdol.roomescape.order.infrastructure.persistence
import com.sangdol.common.persistence.PersistableBaseEntity
import jakarta.persistence.Entity
import jakarta.persistence.Table
import java.time.Instant
@Entity
@Table(name = "post_order_tasks")
class PostOrderTaskEntity(
id: Long,
val reservationId: Long,
val paymentKey: String,
val trial: Int,
val nextRetryAt: Instant
) : PersistableBaseEntity(id)

View File

@ -0,0 +1,6 @@
package com.sangdol.roomescape.order.infrastructure.persistence
import org.springframework.data.jpa.repository.JpaRepository
interface PostOrderTaskRepository : JpaRepository<PostOrderTaskEntity, Long> {
}

View File

@ -238,3 +238,26 @@ create table if not exists canceled_payment(
constraint uk_canceled_payment__paymentId unique (payment_id), constraint uk_canceled_payment__paymentId unique (payment_id),
constraint fk_canceled_payment__paymentId foreign key (payment_id) references payment(id) constraint fk_canceled_payment__paymentId foreign key (payment_id) references payment(id)
); );
create table if not exists payment_attempts(
id bigint primary key,
reservation_id bigint not null,
result varchar(20) not null,
error_code varchar(50) null,
message text null,
created_at datetime(6) not null,
created_by bigint not null,
constraint fk_payment_attempts__reservation_id foreign key (reservation_id) references reservation (id),
index idx_payment_attempts__reservation_id_result (reservation_id, result)
);
create table if not exists post_order_tasks(
id bigint primary key,
reservation_id bigint not null,
payment_key varchar(255) not null,
trial int not null,
next_retry_at datetime(6) not null,
constraint uk_post_order_tasks__reservation_id unique (reservation_id)
);