diff --git a/src/main/java/com/mindway/server/v2/MindWayV2Application.java b/src/main/java/com/mindway/server/v2/MindWayV2Application.java index e90e2d7..d57d974 100644 --- a/src/main/java/com/mindway/server/v2/MindWayV2Application.java +++ b/src/main/java/com/mindway/server/v2/MindWayV2Application.java @@ -1,11 +1,20 @@ package com.mindway.server.v2; +import com.sun.jna.platform.mac.SystemB; +import jakarta.annotation.PostConstruct; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; +import java.util.TimeZone; + +@EnableScheduling @SpringBootApplication public class MindWayV2Application { + @PostConstruct + public void started() {TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));} + public static void main(String[] args) { SpringApplication.run(MindWayV2Application.class, args); } diff --git a/src/main/java/com/mindway/server/v2/domain/goal/scheduler/GoalScheduler.java b/src/main/java/com/mindway/server/v2/domain/goal/scheduler/GoalScheduler.java new file mode 100644 index 0000000..52c436f --- /dev/null +++ b/src/main/java/com/mindway/server/v2/domain/goal/scheduler/GoalScheduler.java @@ -0,0 +1,16 @@ +package com.mindway.server.v2.domain.goal.scheduler; + +import com.mindway.server.v2.domain.goal.service.GoalsDeleteService; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Scheduled; + +@RequiredArgsConstructor +public class GoalScheduler { + + private final GoalsDeleteService goalsDeleteService; + + @Scheduled(cron = "0 0 0 * * MON", zone = "Asia/Seoul") + public void deleteGoals() { + goalsDeleteService.execute(); + } +} diff --git a/src/main/java/com/mindway/server/v2/domain/goal/service/GoalsDeleteService.java b/src/main/java/com/mindway/server/v2/domain/goal/service/GoalsDeleteService.java new file mode 100644 index 0000000..798b740 --- /dev/null +++ b/src/main/java/com/mindway/server/v2/domain/goal/service/GoalsDeleteService.java @@ -0,0 +1,5 @@ +package com.mindway.server.v2.domain.goal.service; + +public interface GoalsDeleteService { + void execute(); +} diff --git a/src/main/java/com/mindway/server/v2/domain/goal/service/impl/GoalsDeleteServiceImpl.java b/src/main/java/com/mindway/server/v2/domain/goal/service/impl/GoalsDeleteServiceImpl.java new file mode 100644 index 0000000..3e61cbd --- /dev/null +++ b/src/main/java/com/mindway/server/v2/domain/goal/service/impl/GoalsDeleteServiceImpl.java @@ -0,0 +1,18 @@ +package com.mindway.server.v2.domain.goal.service.impl; + +import com.mindway.server.v2.domain.goal.repository.GoalRepository; +import com.mindway.server.v2.domain.goal.service.GoalsDeleteService; +import com.mindway.server.v2.global.annotation.ServiceWithTransaction; +import lombok.RequiredArgsConstructor; + +@ServiceWithTransaction +@RequiredArgsConstructor +public class GoalsDeleteServiceImpl implements GoalsDeleteService { + + private final GoalRepository goalRepository; + + public void execute() { + goalRepository.deleteAll(); + } + +}