Queue.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\controller;
  15. use library\Controller;
  16. use think\Console;
  17. /**
  18. * 系统系统任务
  19. * Class Queue
  20. * @package app\admin\controller
  21. */
  22. class Queue extends Controller
  23. {
  24. /**
  25. * 绑定数据表
  26. * @var string
  27. */
  28. protected $table = 'SystemQueue';
  29. /**
  30. * 系统系统任务
  31. * @auth true
  32. * @menu true
  33. * @throws \think\Exception
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. * @throws \think\exception\DbException
  37. * @throws \think\exception\PDOException
  38. */
  39. public function index()
  40. {
  41. if (session('admin_user.username') === 'admin') try {
  42. $this->cmd = 'php ' . env('root_path') . 'think xtask:start';
  43. $this->message = Console::call('xtask:state')->fetch();
  44. } catch (\Exception $exception) {
  45. $this->message = $exception->getMessage();
  46. }
  47. $this->title = '系统任务管理';
  48. $query = $this->_query($this->table)->dateBetween('create_at,end_at');
  49. $query->like('title,preload')->equal('status')->order('id desc')->page();
  50. }
  51. /**
  52. * 重启系统任务
  53. * @auth true
  54. * @throws \think\Exception
  55. * @throws \think\exception\PDOException
  56. */
  57. public function redo()
  58. {
  59. $this->_save($this->table, ['status' => '1']);
  60. }
  61. /**
  62. * 删除系统任务
  63. * @auth true
  64. * @throws \think\Exception
  65. * @throws \think\exception\PDOException
  66. */
  67. public function remove()
  68. {
  69. $this->_delete($this->table);
  70. }
  71. }