master
parent
43a1916b83
commit
e03a90f456
Binary file not shown.
@ -0,0 +1,23 @@
|
|||||||
|
package com.jingcheng.cms.handler;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.service.EmployeeService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EmployeeJobHandler {
|
||||||
|
|
||||||
|
private final EmployeeService employeeService;
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 1 * * ?")
|
||||||
|
public void syncAge() {
|
||||||
|
|
||||||
|
employeeService.syncAge();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.jingcheng.cms.listener;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.service.EmployeeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class StartListener implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmployeeService employeeService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
//todo 执行一次
|
||||||
|
employeeService.syncAge();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue