Authored by mali

手动执行定时任务

1 package com.yoho.ufo.restapi; 1 package com.yoho.ufo.restapi;
2 2
3 import com.yoho.quartz.job.YhJob; 3 import com.yoho.quartz.job.YhJob;
  4 +import com.yoho.ufo.service.model.*;
  5 +import com.yoho.ufo.service.model.ApiResponse;
4 import org.springframework.beans.BeansException; 6 import org.springframework.beans.BeansException;
5 import org.springframework.context.ApplicationContext; 7 import org.springframework.context.ApplicationContext;
6 import org.springframework.context.ApplicationContextAware; 8 import org.springframework.context.ApplicationContextAware;
7 import org.springframework.stereotype.Controller; 9 import org.springframework.stereotype.Controller;
8 import org.springframework.web.bind.annotation.RequestMapping; 10 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.RequestParam; 11 import org.springframework.web.bind.annotation.RequestParam;
  12 +import org.springframework.web.bind.annotation.ResponseBody;
10 13
11 /** 14 /**
12 * Created by li.ma on 2019/2/1. 15 * Created by li.ma on 2019/2/1.
@@ -22,11 +25,11 @@ public class ScheduledManualController implements ApplicationContextAware{ @@ -22,11 +25,11 @@ public class ScheduledManualController implements ApplicationContextAware{
22 } 25 }
23 26
24 @RequestMapping(value = "/scheduledManual") 27 @RequestMapping(value = "/scheduledManual")
25 - public String scheduledManual(@RequestParam(name = "scheduledName",required = true) String scheduledName) { 28 + @ResponseBody
  29 + public ApiResponse scheduledManual(@RequestParam(name = "scheduledName",required = true) String scheduledName) {
26 30
27 YhJob jobObject = applicationContext.getBean(scheduledName, YhJob.class); 31 YhJob jobObject = applicationContext.getBean(scheduledName, YhJob.class);
28 jobObject.process(null); 32 jobObject.process(null);
29 -  
30 - return "SUCCESS"; 33 + return new ApiResponse(200, "处理成功", null);
31 } 34 }
32 } 35 }