Skip to content

Commit

Permalink
feat: 유효 기간 컬럼 추가(1년) #44
Browse files Browse the repository at this point in the history
  • Loading branch information
PgmJun committed Feb 6, 2024
1 parent fd4fb56 commit 3c65445
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/nice/petudio/domain/gift/Gift.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 3c65445

Please sign in to comment.