fix(gift): 수취인 정보 없는 선물의 전달 완료를 차단한다
This commit is contained in:
+8
-1
@@ -84,4 +84,11 @@ class GiftDelivery(
|
||||
|
||||
@Column(name = "undeliverable_reason", length = 255)
|
||||
var undeliverableReason: String? = null
|
||||
) : BaseEntity()
|
||||
) : BaseEntity() {
|
||||
fun hasCompleteRecipientInformation() = listOf(
|
||||
recipientName,
|
||||
recipientPhoneNumber,
|
||||
recipientZipCode,
|
||||
recipientAddress
|
||||
).none { it.isNullOrBlank() }
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ class GiftAdminService(
|
||||
val gift = giftRepository.findByApplicationNo(applicationNo) ?: throw invalidRequest()
|
||||
if (gift.status != GiftStatus.INSPECTION_COMPLETED) throw invalidRequest()
|
||||
val delivery = giftDeliveryRepository.findByGiftId(requireNotNull(gift.id)) ?: throw invalidRequest()
|
||||
if (!delivery.hasCompleteRecipientInformation()) throw invalidRequest()
|
||||
|
||||
gift.status = GiftStatus.DELIVERED
|
||||
delivery.deliveredAt = now
|
||||
|
||||
Reference in New Issue
Block a user