From 3c654453d0553c883663ecd581e61a5972032091 Mon Sep 17 00:00:00 2001 From: PgmJun Date: Tue, 6 Feb 2024 18:24:34 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9C=A0=ED=9A=A8=20=EA=B8=B0=EA=B0=84?= =?UTF-8?q?=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80(1=EB=85=84)=20#44?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/nice/petudio/domain/gift/Gift.java | 8 +++++++- src/main/resources/sql/schema.sql | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nice/petudio/domain/gift/Gift.java b/src/main/java/com/nice/petudio/domain/gift/Gift.java index 36beee5..b054f74 100644 --- a/src/main/java/com/nice/petudio/domain/gift/Gift.java +++ b/src/main/java/com/nice/petudio/domain/gift/Gift.java @@ -1,13 +1,14 @@ package com.nice.petudio.domain.gift; +import com.fasterxml.jackson.annotation.JsonFormat; import com.nice.petudio.domain.base.BaseEntity; -import com.nice.petudio.domain.concept.ConceptInfo; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -39,11 +40,16 @@ public class Gift extends BaseEntity { @Column(name = "is_used", nullable = false) private Boolean isUsed; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") + @Column(name = "expired_at", updatable = false) + private LocalDateTime expiredAt; + public static Gift newInstance(Long memberId, String code) { return Gift.builder() .code(code) .buyerId(memberId) .isUsed(false) + .expiredAt(LocalDateTime.now().plusYears(1L)) .build(); } diff --git a/src/main/resources/sql/schema.sql b/src/main/resources/sql/schema.sql index a2ecf44..0442696 100644 --- a/src/main/resources/sql/schema.sql +++ b/src/main/resources/sql/schema.sql @@ -99,6 +99,7 @@ CREATE TABLE `gifts` `user_id` bigint NULL, `gift_code` varchar(32) NOT NULL, `is_used` boolean NOT NULL, + `expired_at` datetime NOT NULL, `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP );