Skip to content

Commit

Permalink
refactor: Instant를 모두 LocalDateTime으로 변경 (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Feb 12, 2024
1 parent 94935a0 commit b56a9a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/teumteum/alert/domain/AlertRepository.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,5 +11,5 @@ public interface AlertRepository extends JpaRepository<Alert, Long> {
List<Alert> findAllByUserId(Long userId);

@Query("select a from alert as a where a.createdAt <= :createdAt")
List<Alert> findAllByCreatedAt(@Param("createdAt") Instant createdAt);
List<Alert> findAllByCreatedAt(@Param("createdAt") LocalDateTime createdAt);
}
4 changes: 2 additions & 2 deletions src/main/java/net/teumteum/alert/domain/AlertService.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -26,7 +26,7 @@ public record AlertResponse(
String title,
String body,
String type,
Instant createdAt,
LocalDateTime createdAt,
boolean isRead
) {

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/teumteum/core/entity/TimeBaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
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;
import org.springframework.data.annotation.CreatedDate;
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;
}

0 comments on commit b56a9a8

Please sign in to comment.