Fences.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace catchAdmin\fences\model;
  3. use catcher\base\CatchModel as Model;
  4. use catchAdmin\fences\model\FencesGet;
  5. use catchAdmin\permissions\model\DataRangScopeTrait;
  6. class Fences extends Model
  7. {
  8. use FencesGet;
  9. use DataRangScopeTrait;
  10. // 表名
  11. public $name = 'fences';
  12. // 数据库字段映射
  13. public $field = array(
  14. 'id',
  15. // 围栏名称
  16. 'name',
  17. // 围栏类型
  18. 'fence_shape',
  19. // 围栏类别
  20. 'fence_type',
  21. // 围栏信息
  22. 'fence_info',
  23. // 作用部门
  24. 'departments',
  25. // 推送用户
  26. 'push_users',
  27. // 进围栏检测
  28. 'is_check_in',
  29. // 进围栏检测时间
  30. 'in_fence_time_area',
  31. // 出围栏检测
  32. 'is_check_out',
  33. // 出围栏检测时间
  34. 'out_fence_time_area',
  35. // 推送间隔
  36. 'sent_interval',
  37. // 备注
  38. 'remark',
  39. // 创建人ID
  40. 'creator_id',
  41. // 创建时间
  42. 'created_at',
  43. // 更新时间
  44. 'updated_at',
  45. // 软删除
  46. 'deleted_at',
  47. );
  48. public function getList()
  49. {
  50. // 不分页
  51. if (property_exists($this, 'paginate') && $this->paginate === false) {
  52. return $this->dataRange()
  53. ->catchSearch()
  54. ->field('*')
  55. ->catchOrder()
  56. ->where('fence_type', 0)
  57. ->append(['type_name','in_fence_time_area_text','out_fence_time_area_text','department_name','level'])
  58. ->creator()
  59. ->select();
  60. }
  61. // 分页列表
  62. return $this->dataRange()
  63. ->catchSearch()
  64. ->field('*')
  65. ->catchOrder()
  66. ->where('fence_type', 0)
  67. ->append(['type_name','in_fence_time_area_text','out_fence_time_area_text','department_name','level'])
  68. ->creator()
  69. ->paginate();
  70. }
  71. public function getSchoolFenceList()
  72. {
  73. // 不分页
  74. if (property_exists($this, 'paginate') && $this->paginate === false) {
  75. $res= $this->dataRange()
  76. ->catchSearch()
  77. ->field('*')
  78. ->catchOrder()
  79. ->where('fence_type', 2)
  80. ->append(['type_name','department_name','level'])
  81. ->creator()
  82. ->select();
  83. // var_dump($this->getLastSql());
  84. return $res;
  85. }
  86. // 分页列表
  87. $res= $this->dataRange()
  88. ->catchSearch()
  89. ->field('*')
  90. ->catchOrder()
  91. ->where('fence_type', 2)
  92. ->append(['type_name','department_name','level'])
  93. ->creator()
  94. ->paginate();
  95. // var_dump($this->getLastSql());
  96. return $res;
  97. }
  98. public function getKqFenceList()
  99. {
  100. // 不分页
  101. if (property_exists($this, 'paginate') && $this->paginate === false) {
  102. $res= $this->dataRange()
  103. ->catchSearch()
  104. ->field('*')
  105. ->catchOrder()
  106. ->where('fence_type', 3)
  107. ->append(['type_name','department_name','level'])
  108. ->creator()
  109. ->select();
  110. // var_dump($this->getLastSql());
  111. return $res;
  112. }
  113. // 分页列表
  114. $res= $this->dataRange()
  115. ->catchSearch()
  116. ->field('*')
  117. ->catchOrder()
  118. ->where('fence_type', 3)
  119. ->append(['type_name','department_name','level'])
  120. ->creator()
  121. ->paginate();
  122. // var_dump($this->getLastSql());
  123. return $res;
  124. }
  125. }