控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Command.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Command extends Model
  5. {
  6. // 自动写入时间戳字段
  7. protected $autoWriteTimestamp = true;
  8. // 追加属性
  9. protected $append = [
  10. 'execute_time_text',
  11. 'type_text',
  12. 'status_text',
  13. ];
  14. public function getStatusList()
  15. {
  16. return ['失败', '成功'];
  17. }
  18. public function getExecuteTimeTextAttr($value, $data)
  19. {
  20. $value = $value ? $value : $data['execute_time'];
  21. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  22. }
  23. public function getTypeTextAttr($value, $data)
  24. {
  25. $value = $value ? $value : $data['type'];
  26. $list = ['crud' => '一键生成CRUD', 'menu' => '一键生成菜单'];
  27. return isset($list[$value]) ? $list[$value] : '';
  28. }
  29. public function getStatusTextAttr($value, $data)
  30. {
  31. $value = $value ? $value : $data['status'];
  32. $list = $this->getStatusList();
  33. return isset($list[$value]) ? $list[$value] : '';
  34. }
  35. protected function setExecuteTimeAttr($value)
  36. {
  37. return $value && !is_numeric($value) ? strtotime($value) : $value;
  38. }
  39. }