SystemQueue.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免费声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  13. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  14. // +----------------------------------------------------------------------
  15. namespace app\admin\model;
  16. use think\admin\Model;
  17. /**
  18. * 系统任务模型
  19. * Class SystemQueue
  20. * @package app\admin\model
  21. */
  22. class SystemQueue extends Model
  23. {
  24. /**
  25. * 格式化计划时间
  26. * @param float $value
  27. * @return string
  28. */
  29. public function getExecTimeAttr(float $value): string
  30. {
  31. return format_datetime($value);
  32. }
  33. /**
  34. * 执行开始时间处理
  35. * @param mixed $value
  36. * @return string
  37. */
  38. public function getEnterTimeAttr($value): string
  39. {
  40. return floatval($value) > 0 ? format_datetime($value) : '';
  41. }
  42. /**
  43. * 执行结束时间处理
  44. * @param mixed $value
  45. * @param array $data
  46. * @return string
  47. */
  48. public function getOuterTimeAttr($value, array $data): string
  49. {
  50. if ($value > 0 && $value > $data['enter_time']) {
  51. return sprintf(" %.4f 秒", $data['outer_time'] - $data['enter_time']);
  52. } else {
  53. return ' - ';
  54. }
  55. }
  56. /**
  57. * 格式化创建时间
  58. * @param string $value
  59. * @return string
  60. */
  61. public function getCreateAtAttr(string $value): string
  62. {
  63. return format_datetime($value);
  64. }
  65. }