DashboardController.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.xxl.job.controller;
  2. import com.xxl.job.core.biz.model.ReturnT;
  3. import com.xxl.job.service.XxlJobService;
  4. import org.springframework.beans.propertyeditors.CustomDateEditor;
  5. import org.springframework.web.bind.WebDataBinder;
  6. import org.springframework.web.bind.annotation.InitBinder;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import javax.annotation.Resource;
  10. import java.text.SimpleDateFormat;
  11. import java.util.Date;
  12. import java.util.Map;
  13. /**
  14. * @Description
  15. * @Author bqyang
  16. * @Date 2025/1/7 09:48
  17. * @Version 1.0
  18. */
  19. @RestController
  20. @RequestMapping("/xxl-job-admin")
  21. public class DashboardController {
  22. @Resource
  23. private XxlJobService xxlJobService;
  24. @RequestMapping("/chartInfo")
  25. public ReturnT<Map<String, Object>> chartInfo(Date startDate, Date endDate) {
  26. ReturnT<Map<String, Object>> chartInfo = xxlJobService.chartInfo(startDate, endDate);
  27. return chartInfo;
  28. }
  29. @InitBinder
  30. public void initBinder(WebDataBinder binder) {
  31. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  32. dateFormat.setLenient(false);
  33. binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
  34. }
  35. @RequestMapping("/dashboardInfo")
  36. public ReturnT<Map<String, Object>> dashboardInfo() {
  37. Map<String, Object> dashboardInfo = xxlJobService.dashboardInfo();
  38. return new ReturnT<>(dashboardInfo);
  39. }
  40. }