Skip to content

Commit

Permalink
refactor: 절기 등록 스케줄링 작업으로부터 알림 전송 관심사를 분리
Browse files Browse the repository at this point in the history
NotifyResultAspect를 적용하여 알림 전송 관심사를 절기 등록 스케줄링 작업으로부터 분리
  • Loading branch information
csct3434 committed May 15, 2024
1 parent 6b781f4 commit d05146c
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,20 @@
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import today.seasoning.seasoning.common.aws.SnsService;
import today.seasoning.seasoning.common.aspect.NotifyResult;
import today.seasoning.seasoning.solarterm.service.RegisterSolarTermsService;

@Service
@RequiredArgsConstructor
public class RegisterNextYearSolarTermsService {

private final SnsService snsService;
private final RegisterSolarTermsService registerSolarTermsService;

@Scheduled(cron = "0 0 0 1 12 *")
@NotifyResult(name = "절기 등록 작업")
public void doService() {
int nextYear = LocalDate.now().getYear() + 1;

try {
registerSolarTermsService.doService(nextYear);

snsService.publish("[시즈닝] " + nextYear + "년 절기 등록 완료");
} catch (Exception e) {
snsService.publish("[시즈닝] ERROR - " + nextYear + "년 절기 등록 실패");
}
registerSolarTermsService.doService(nextYear);
}

}

0 comments on commit d05146c

Please sign in to comment.