CrontabController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller\crontab;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\crontab\CrontabLists;
  17. use app\adminapi\logic\crontab\CrontabLogic;
  18. use app\adminapi\validate\crontab\CrontabValidate;
  19. /**
  20. * 定时任务控制器
  21. * Class CrontabController
  22. * @package app\adminapi\controller\crontab
  23. */
  24. class CrontabController extends BaseAdminController
  25. {
  26. /**
  27. * @notes 定时任务列表
  28. * @return \think\response\Json
  29. * @author 段誉
  30. * @date 2022/3/29 14:27
  31. */
  32. public function lists()
  33. {
  34. return $this->dataLists(new CrontabLists());
  35. }
  36. /**
  37. * @notes 添加定时任务
  38. * @return \think\response\Json
  39. * @author 段誉
  40. * @date 2022/3/29 14:27
  41. */
  42. public function add()
  43. {
  44. $params = (new CrontabValidate())->post()->goCheck('add');
  45. $result = CrontabLogic::add($params);
  46. if($result) {
  47. return $this->success('添加成功', [], 1, 1);
  48. }
  49. return $this->fail(CrontabLogic::getError());
  50. }
  51. /**
  52. * @notes 查看定时任务详情
  53. * @return \think\response\Json
  54. * @author 段誉
  55. * @date 2022/3/29 14:27
  56. */
  57. public function detail()
  58. {
  59. $params = (new CrontabValidate())->goCheck('detail');
  60. $result = CrontabLogic::detail($params);
  61. return $this->data($result);
  62. }
  63. /**
  64. * @notes 编辑定时任务
  65. * @return \think\response\Json
  66. * @author 段誉
  67. * @date 2022/3/29 14:27
  68. */
  69. public function edit()
  70. {
  71. $params = (new CrontabValidate())->post()->goCheck('edit');
  72. $result = CrontabLogic::edit($params);
  73. if($result) {
  74. return $this->success('编辑成功', [], 1, 1);
  75. }
  76. return $this->fail(CrontabLogic::getError());
  77. }
  78. /**
  79. * @notes 删除定时任务
  80. * @return \think\response\Json
  81. * @author 段誉
  82. * @date 2022/3/29 14:27
  83. */
  84. public function delete()
  85. {
  86. $params = (new CrontabValidate())->post()->goCheck('delete');
  87. $result = CrontabLogic::delete($params);
  88. if($result) {
  89. return $this->success('删除成功', [], 1, 1);
  90. }
  91. return $this->fail('删除失败');
  92. }
  93. /**
  94. * @notes 操作定时任务
  95. * @return \think\response\Json
  96. * @author 段誉
  97. * @date 2022/3/29 14:28
  98. */
  99. public function operate()
  100. {
  101. $params = (new CrontabValidate())->post()->goCheck('operate');
  102. $result = CrontabLogic::operate($params);
  103. if($result) {
  104. return $this->success('操作成功', [], 1, 1);
  105. }
  106. return $this->fail(CrontabLogic::getError());
  107. }
  108. /**
  109. * @notes 获取规则执行时间
  110. * @return \think\response\Json
  111. * @author 段誉
  112. * @date 2022/3/29 14:28
  113. */
  114. public function expression()
  115. {
  116. $params = (new CrontabValidate())->goCheck('expression');
  117. $result = CrontabLogic::expression($params);
  118. return $this->data($result);
  119. }
  120. }