JobInfoController.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package com.xxl.job.admin.controller;
  2. import com.xxl.job.admin.core.model.XxlJobGroup;
  3. import com.xxl.job.admin.dao.IXxlJobGroupDao;
  4. import com.xxl.job.admin.service.IXxlJobService;
  5. import com.xxl.job.core.biz.model.ReturnT;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.ui.Model;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestParam;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. import javax.annotation.Resource;
  12. import java.util.List;
  13. import java.util.Map;
  14. /**
  15. * index controller
  16. * @author xuxueli 2015-12-19 16:13:16
  17. */
  18. @Controller
  19. @RequestMapping("/jobinfo")
  20. public class JobInfoController {
  21. @Resource
  22. private IXxlJobGroupDao xxlJobGroupDao;
  23. @Resource
  24. private IXxlJobService xxlJobService;
  25. @RequestMapping
  26. public String index(Model model) {
  27. // 任务组
  28. List<XxlJobGroup> jobGroupList = xxlJobGroupDao.findAll();
  29. model.addAttribute("JobGroupList", jobGroupList);
  30. return "jobinfo/jobinfo.index";
  31. }
  32. @RequestMapping("/pageList")
  33. @ResponseBody
  34. public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,
  35. @RequestParam(required = false, defaultValue = "10") int length,
  36. int jobGroup, String executorHandler, String filterTime) {
  37. return xxlJobService.pageList(start, length, jobGroup, executorHandler, filterTime);
  38. }
  39. @RequestMapping("/add")
  40. @ResponseBody
  41. public ReturnT<String> add(int jobGroup, String jobCron, String jobDesc, String author, String alarmEmail,
  42. String executorHandler, String executorParam, int glueSwitch, String glueSource, String glueRemark, String childJobKey) {
  43. return xxlJobService.add(jobGroup, jobCron, jobDesc, author, alarmEmail,
  44. executorHandler, executorParam,
  45. glueSwitch, glueSource, glueRemark, childJobKey);
  46. }
  47. @RequestMapping("/reschedule")
  48. @ResponseBody
  49. public ReturnT<String> reschedule(int jobGroup, String jobName, String jobCron, String jobDesc, String author, String alarmEmail,
  50. String executorHandler, String executorParam, int glueSwitch, String childJobKey) {
  51. return xxlJobService.reschedule(jobGroup, jobName, jobCron, jobDesc, author, alarmEmail,
  52. executorHandler, executorParam, glueSwitch, childJobKey);
  53. }
  54. @RequestMapping("/remove")
  55. @ResponseBody
  56. public ReturnT<String> remove(int jobGroup, String jobName) {
  57. return xxlJobService.remove(jobGroup, jobName);
  58. }
  59. @RequestMapping("/pause")
  60. @ResponseBody
  61. public ReturnT<String> pause(int jobGroup, String jobName) {
  62. return xxlJobService.pause(jobGroup, jobName);
  63. }
  64. @RequestMapping("/resume")
  65. @ResponseBody
  66. public ReturnT<String> resume(int jobGroup, String jobName) {
  67. return xxlJobService.resume(jobGroup, jobName);
  68. }
  69. @RequestMapping("/trigger")
  70. @ResponseBody
  71. public ReturnT<String> triggerJob(int jobGroup, String jobName) {
  72. return xxlJobService.triggerJob(jobGroup, jobName);
  73. }
  74. }