12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\common\model;
- use app\common\library\Redis;
- use think\Cache;
- use think\Log;
- use think\Model;
- class Transfer extends Model
- {
- // 表名
- protected $table = 'transfer';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- // 追加属性
- protected $append = [
- 'backup_status_text',
- 'transfer_status_text'
- ];
-
- public function getBackupStatusText()
- {
- return ['0' => '未备份','1' => '备份中','2' => '备份完成','3' => '备份失败'];
- }
- public function getTransferStatusText()
- {
- return ['0' => '未迁移','1' => '迁移中','2' => '迁移完成','3'=> '迁移失败'];
- }
- public function getBackupStatusTextAttr($value, $data)
- {
- $value = $value ? $value : $data['backup_status'];
- $list = $this->getBackupStatusText();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getTransferStatusTextAttr($value, $data)
- {
- $value = $value ? $value : $data['transfer_status'];
- $list = $this->getTransferStatusText();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|