From 0bc4609d23b519588dfc661cc3ac99c8aab2815a Mon Sep 17 00:00:00 2001 From: chaeyeon-yang Date: Wed, 3 Jul 2024 18:03:24 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=81=ED=92=88=20=EC=8B=9C=EC=9E=91?= =?UTF-8?q?=EB=82=A0=EC=A7=9C,=20=EB=A7=8C=EA=B8=B0=20=EB=82=A0=EC=A7=9C?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/hana/api/group/entity/Group.java | 5 ++++- .../com/hana/common/scheduler/DynamicSchedulerService.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hana/api/group/entity/Group.java b/src/main/java/com/hana/api/group/entity/Group.java index 100ce07..184b7f2 100644 --- a/src/main/java/com/hana/api/group/entity/Group.java +++ b/src/main/java/com/hana/api/group/entity/Group.java @@ -47,9 +47,12 @@ public class Group extends BaseEntity { private String wakeupTime; @Column + @Setter private LocalDateTime startedAt; + @Column - private LocalDateTime endeddAt; + @Setter + private LocalDateTime endedAt; @Column(nullable = false) @ColumnDefault("0") diff --git a/src/main/java/com/hana/common/scheduler/DynamicSchedulerService.java b/src/main/java/com/hana/common/scheduler/DynamicSchedulerService.java index a58a545..2b4bbaf 100644 --- a/src/main/java/com/hana/common/scheduler/DynamicSchedulerService.java +++ b/src/main/java/com/hana/common/scheduler/DynamicSchedulerService.java @@ -33,10 +33,15 @@ public void scheduleStatusUpdate(long groupId) { .withMinute(0) .withSecond(0); + // 차주 월요일로부터 3개월 후의 날짜 계산 + LocalDateTime threeMonthsLater = nextMonday.plusMonths(3); + // 스케줄링할 작업 정의 Runnable task = () -> { Group group = groupRepository.findById(groupId).orElseThrow(() -> new BaseException(BaseResponseStatus.GROUPS_EMPTY_GROUP_ID)); group.setStatus(2); + group.setStartedAt(nextMonday); + group.setEndedAt(threeMonthsLater); groupRepository.save(group); };