CrontabLists.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\lists\crontab;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\Crontab;
  17. /**
  18. * 定时任务列表
  19. * Class CrontabLists
  20. * @package app\adminapi\lists\crontab
  21. */
  22. class CrontabLists extends BaseAdminDataLists
  23. {
  24. /**
  25. * @notes 定时任务列表
  26. * @return array
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\DbException
  29. * @throws \think\db\exception\ModelNotFoundException
  30. * @author 段誉
  31. * @date 2022/3/29 14:30
  32. */
  33. public function lists(): array
  34. {
  35. $field = 'id,name,type,type as type_desc,command,params,expression,
  36. status,status as status_desc,error,last_time,time,max_time';
  37. $lists = Crontab::field($field)
  38. ->limit($this->limitOffset, $this->limitLength)
  39. ->order('id', 'desc')
  40. ->select()
  41. ->toArray();
  42. return $lists;
  43. }
  44. /**
  45. * @notes 定时任务数量
  46. * @return int
  47. * @author 段誉
  48. * @date 2022/3/29 14:38
  49. */
  50. public function count(): int
  51. {
  52. return Crontab::count();
  53. }
  54. }