어드민 스케줄 등록 : 임가패널수만큼 월별현황 추가.
This commit is contained in:
@@ -7,9 +7,11 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
@ComponentScan(basePackages = "app.module")
|
||||
public class AdminApplication extends SpringBootServletInitializer {
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.admin.usecase.schedule.autoSchedules.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class AutoSchedulesDao implements AutoSchedulesPortOut {
|
||||
|
||||
private final AutoSchedulesMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Optional<Boolean> operate() {
|
||||
try {
|
||||
mapper.createMonthlyInputStatus();
|
||||
|
||||
return Optional.of(true);
|
||||
} catch (Exception e) {
|
||||
// 예외 발생 시 false 반환
|
||||
return Optional.of(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.admin.usecase.schedule.autoSchedules.adapters.persistence;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AutoSchedulesMapper {
|
||||
|
||||
void createMonthlyInputStatus();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.admin.usecase.schedule.autoSchedules.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortIn;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class AutoSchedulesController {
|
||||
|
||||
private final AutoSchedulesPortIn portIn;
|
||||
|
||||
public AutoSchedulesController(AutoSchedulesPortIn portIn) {
|
||||
this.portIn = portIn;
|
||||
}
|
||||
|
||||
// 매 월 1일 1초 마다 실행되는 스케줄러
|
||||
@Scheduled(cron = "1 0 0 1 * *")
|
||||
public void fetchArticlesPeriodically() {
|
||||
portIn.operate();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 스케쥴 있다면.. 추가.
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.admin.usecase.schedule.autoSchedules.ports;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AutoSchedulesPortIn {
|
||||
|
||||
Optional<Boolean> operate();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.admin.usecase.schedule.autoSchedules.ports;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AutoSchedulesPortOut {
|
||||
|
||||
Optional<Boolean> operate();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.schedule.autoSchedules.ports.application;
|
||||
|
||||
import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortIn;
|
||||
import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class AutoSchedulesService implements AutoSchedulesPortIn {
|
||||
|
||||
private final AutoSchedulesPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Optional<Boolean> operate() {
|
||||
return portOut.operate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user