diff --git a/src/main/java/agridata/spring/service/NotificationScheduler.java b/src/main/java/agridata/spring/service/NotificationScheduler.java index 92fa209..cb436be 100644 --- a/src/main/java/agridata/spring/service/NotificationScheduler.java +++ b/src/main/java/agridata/spring/service/NotificationScheduler.java @@ -11,9 +11,8 @@ public class NotificationScheduler { private final NotificationServiceImpl notificationServiceImpl; // 주기적으로 실행할 작업을 정의할 때 사용 -// @Scheduled(cron = "0 0 0 * * *") // 매 시간 정각마다 + @Scheduled(cron = "0 0 0 * * *") // 매 시간 정각마다 - @Scheduled(cron = "0 */1 * * * *") // 매 1분마다 실행 public void runNotificationJob() { notificationServiceImpl.checkAndLogPriceAlerts(); } diff --git a/src/main/java/agridata/spring/service/impl/NotificationServiceImpl.java b/src/main/java/agridata/spring/service/impl/NotificationServiceImpl.java index 2cbb997..5d6bde2 100644 --- a/src/main/java/agridata/spring/service/impl/NotificationServiceImpl.java +++ b/src/main/java/agridata/spring/service/impl/NotificationServiceImpl.java @@ -91,8 +91,9 @@ countyCode, getToday(), getToday() int price = Integer.parseInt(priceText); boolean shouldNotify = - (n.getType() == Type.WHOLESALE && price > n.getTargetPrice()) || - (n.getType() == Type.RETAIL && price < n.getTargetPrice()); + (n.getType() == Type.WHOLESALE && price >= n.getTargetPrice()) || + (n.getType() == Type.RETAIL && price <= n.getTargetPrice()); + if (shouldNotify) { String direction = (n.getType() == Type.WHOLESALE) ? "상승" : "하락"; NotificationLog logEntity = NotificationLog.builder() diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 39f4e08..b72bdc1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -24,7 +24,7 @@ spring: generate_ddl: true use_sql_comments: true hbm2ddl: - auto: update + auto: create default_batch_fetch_size: 1000 database: mysql