Skip to content

Commit

Permalink
Merge pull request #73 from Team-MindWay/72-goal-delete-implement
Browse files Browse the repository at this point in the history
🔀 :: 주기적으로 목표 삭제
  • Loading branch information
Umjiseung authored Apr 13, 2024
2 parents e7ca736 + 7959cb4 commit 390f5f7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/mindway/server/v2/MindWayV2Application.java
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mindway.server.v2.domain.goal.service;

public interface GoalsDeleteService {
void execute();
}
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit 390f5f7

Please sign in to comment.