From ef813bec98d952d82ce198a3ada2b447283e64a5 Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:04:50 +0900 Subject: [PATCH] release: 0.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: test 명 완성 * refactor: Instant를 모두 LocalDateTime으로 변경 (#200) --------- Co-authored-by: choidongkuen --- .../java/net/teumteum/alert/domain/AlertRepository.java | 4 ++-- src/main/java/net/teumteum/alert/domain/AlertService.java | 4 ++-- .../teumteum/alert/domain/response/AlertsResponse.java | 4 ++-- .../java/net/teumteum/core/entity/TimeBaseEntity.java | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/teumteum/alert/domain/AlertRepository.java b/src/main/java/net/teumteum/alert/domain/AlertRepository.java index 7c873b68..f5d65c2f 100644 --- a/src/main/java/net/teumteum/alert/domain/AlertRepository.java +++ b/src/main/java/net/teumteum/alert/domain/AlertRepository.java @@ -1,6 +1,6 @@ package net.teumteum.alert.domain; -import java.time.Instant; +import java.time.LocalDateTime; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -11,5 +11,5 @@ public interface AlertRepository extends JpaRepository { List findAllByUserId(Long userId); @Query("select a from alert as a where a.createdAt <= :createdAt") - List findAllByCreatedAt(@Param("createdAt") Instant createdAt); + List findAllByCreatedAt(@Param("createdAt") LocalDateTime createdAt); } diff --git a/src/main/java/net/teumteum/alert/domain/AlertService.java b/src/main/java/net/teumteum/alert/domain/AlertService.java index 667ba257..b8c86283 100644 --- a/src/main/java/net/teumteum/alert/domain/AlertService.java +++ b/src/main/java/net/teumteum/alert/domain/AlertService.java @@ -1,6 +1,6 @@ package net.teumteum.alert.domain; -import java.time.Instant; +import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import lombok.RequiredArgsConstructor; import net.teumteum.alert.domain.response.AlertsResponse; @@ -33,7 +33,7 @@ public AlertsResponse findAllByUserId(Long userId) { @Transactional @Scheduled(cron = EVERY_12AM) public void deleteOneMonthBeforeAlert() { - var deleteTargets = alertRepository.findAllByCreatedAt(Instant.now().minus(1, ChronoUnit.MONTHS)); + var deleteTargets = alertRepository.findAllByCreatedAt(LocalDateTime.now().minus(1, ChronoUnit.MONTHS)); alertRepository.deleteAllInBatch(deleteTargets); } } diff --git a/src/main/java/net/teumteum/alert/domain/response/AlertsResponse.java b/src/main/java/net/teumteum/alert/domain/response/AlertsResponse.java index ef0b9b2d..dd69d155 100644 --- a/src/main/java/net/teumteum/alert/domain/response/AlertsResponse.java +++ b/src/main/java/net/teumteum/alert/domain/response/AlertsResponse.java @@ -1,6 +1,6 @@ package net.teumteum.alert.domain.response; -import java.time.Instant; +import java.time.LocalDateTime; import java.util.List; import net.teumteum.alert.domain.Alert; @@ -26,7 +26,7 @@ public record AlertResponse( String title, String body, String type, - Instant createdAt, + LocalDateTime createdAt, boolean isRead ) { diff --git a/src/main/java/net/teumteum/core/entity/TimeBaseEntity.java b/src/main/java/net/teumteum/core/entity/TimeBaseEntity.java index c074310f..3ce6b966 100644 --- a/src/main/java/net/teumteum/core/entity/TimeBaseEntity.java +++ b/src/main/java/net/teumteum/core/entity/TimeBaseEntity.java @@ -3,6 +3,7 @@ import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; import jakarta.persistence.MappedSuperclass; +import java.time.LocalDateTime; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -10,20 +11,19 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import java.time.Instant; - @Getter @SuperBuilder @NoArgsConstructor @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class TimeBaseEntity { + @CreatedDate @Column(name = "created_at", nullable = false, updatable = false) - private Instant createdAt; + private LocalDateTime createdAt; @LastModifiedDate @Column(name = "updated_at", nullable = false) - private Instant updatedAt; + private LocalDateTime updatedAt; }