SystemTimer.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\adminapi\controller\v1\system;
  3. use app\adminapi\controller\AuthController;
  4. use app\services\system\timer\SystemTimerServices;
  5. use think\facade\App;
  6. class SystemTimer extends AuthController
  7. {
  8. public function __construct(App $app, SystemTimerServices $services)
  9. {
  10. parent::__construct($app);
  11. $this->services = $services;
  12. }
  13. /**
  14. * 获取定时任务列表
  15. * @return mixed
  16. */
  17. public function getTimerList()
  18. {
  19. $where = ['is_del' => 0];
  20. return app('json')->success($this->services->getTimerList($where));
  21. }
  22. /**
  23. * 获取定时任务详情
  24. * @param $id
  25. * @return mixed
  26. */
  27. public function getTimerInfo($id)
  28. {
  29. return app('json')->success($this->services->getTimerInfo($id));
  30. }
  31. /**
  32. * 获取定时任务类型
  33. * @return mixed
  34. */
  35. public function getMarkList()
  36. {
  37. return app('json')->success($this->services->getMarkList());
  38. }
  39. /**
  40. * 保存定时任务
  41. * @return mixed
  42. */
  43. public function saveTimer()
  44. {
  45. $data = $this->request->postMore([
  46. ['id', 0],
  47. ['name', ''],
  48. ['mark', ''],
  49. ['content', ''],
  50. ['type', 0],
  51. ['is_open', 0],
  52. ['week', 0],
  53. ['day', 0],
  54. ['hour', 0],
  55. ['minute', 0],
  56. ['second', 0],
  57. ]);
  58. $this->services->saveTimer($data);
  59. return app('json')->success(100000);
  60. }
  61. /**
  62. * 删除定时任务
  63. * @param $id
  64. * @return mixed
  65. */
  66. public function delTimer($id)
  67. {
  68. $this->services->delTimer($id);
  69. return app('json')->success(100002);
  70. }
  71. /**
  72. * 设置定时任务状态
  73. * @param $id
  74. * @param $is_open
  75. * @return mixed
  76. */
  77. public function setTimerStatus($id, $is_open)
  78. {
  79. $this->services->setTimerStatus($id, $is_open);
  80. return app('json')->success(100014);
  81. }
  82. }