Transfer.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\common\model;
  3. use app\common\library\Redis;
  4. use think\Cache;
  5. use think\Log;
  6. use think\Model;
  7. class Transfer extends Model
  8. {
  9. // 表名
  10. protected $table = 'transfer';
  11. // 自动写入时间戳字段
  12. protected $autoWriteTimestamp = 'int';
  13. // 定义时间戳字段名
  14. protected $createTime = 'createtime';
  15. protected $updateTime = 'updatetime';
  16. // 追加属性
  17. protected $append = [
  18. 'backup_status_text',
  19. 'transfer_status_text'
  20. ];
  21. public function getBackupStatusText()
  22. {
  23. return ['0' => '未备份','1' => '备份中','2' => '备份完成','3' => '备份失败'];
  24. }
  25. public function getTransferStatusText()
  26. {
  27. return ['0' => '未迁移','1' => '迁移中','2' => '迁移完成','3'=> '迁移失败'];
  28. }
  29. public function getBackupStatusTextAttr($value, $data)
  30. {
  31. $value = $value ? $value : $data['backup_status'];
  32. $list = $this->getBackupStatusText();
  33. return isset($list[$value]) ? $list[$value] : '';
  34. }
  35. public function getTransferStatusTextAttr($value, $data)
  36. {
  37. $value = $value ? $value : $data['transfer_status'];
  38. $list = $this->getTransferStatusText();
  39. return isset($list[$value]) ? $list[$value] : '';
  40. }
  41. }