ConfigLog.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace catchAdmin\logs\model;
  3. use catcher\base\CatchModel as Model;
  4. use catchAdmin\system\model\SysDictData;
  5. class ConfigLog extends Model
  6. {
  7. // 表名
  8. public $name = 'send_config_log';
  9. // 数据库字段映射
  10. public $field = array(
  11. 'id',
  12. // 下发内容
  13. 'send_contents',
  14. // 响应内容
  15. 'resp_contents',
  16. // 下发结果 0-待下发 1-下发中 2-下发成功 3-下发失败
  17. 'result',
  18. // 创建人ID
  19. 'creator_id',
  20. // 创建时间
  21. 'created_at',
  22. // 更新时间
  23. 'updated_at',
  24. // 软删除
  25. 'deleted_at',
  26. );
  27. public function getList(){
  28. return $this->catchSearch()
  29. ->order($this->aliasField('id'), 'desc')
  30. ->paginate();
  31. }
  32. public function searchDeviceIdAttr($query, $value, $data)
  33. {
  34. return $query->where('device_id',$value);
  35. }
  36. public function getCreatedAtAttr($value)
  37. {
  38. if($value){
  39. return date('Y-m-d H:i:s',$value);
  40. }
  41. return '';
  42. }
  43. public function getUpdatedAtAttr($value)
  44. {
  45. if($value){
  46. return date('Y-m-d H:i:s',$value);
  47. }
  48. return '';
  49. }
  50. public function getResultAttr($value)
  51. {
  52. return (new SysDictData)->getValueByCode('SendConfigResult',$value);
  53. }
  54. }