1
0

LabelsLists.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\labels;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\labels\Labels;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * Labels列表
  20. * Class LabelsLists
  21. * @package app\adminapi\lists
  22. */
  23. class LabelsLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2024/12/12 17:15
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['label_type','pid'],
  35. '%like%' => ['label_name'],
  36. ];
  37. }
  38. /**
  39. * 获取数据权限
  40. * $this->adminInfo['data_rules']
  41. * province city admin_id sale_group_id sale_id property_head_id
  42. */
  43. public function queryDataWhere(){
  44. $where = [];
  45. // 工程师标签 - 省市权限判断
  46. if(isset($this->params['label_type']) && $this->params['label_type'] == 2){
  47. $data_rules = $this->adminInfo['data_rules'];
  48. if (isset($data_rules['province']) && !empty($data_rules['province'])) {
  49. $where[] = ['province','in' ,$data_rules['province']];
  50. }
  51. if (isset($data_rules['city']) && !empty($data_rules['city'])) {
  52. $where[] = ['city','in' ,$data_rules['city']];
  53. }
  54. }
  55. return $where;
  56. }
  57. /**
  58. * @notes 获取列表
  59. * @return array
  60. * @throws \think\db\exception\DataNotFoundException
  61. * @throws \think\db\exception\DbException
  62. * @throws \think\db\exception\ModelNotFoundException
  63. * @author likeadmin
  64. * @date 2024/12/12 17:15
  65. */
  66. public function lists(): array
  67. {
  68. return Labels::where($this->searchWhere)
  69. ->field(['id', 'label_type', 'label_name','pid','province','city','area_name'])
  70. ->where($this->queryDataWhere())
  71. ->limit($this->limitOffset, $this->limitLength)
  72. ->order(['id' => 'desc'])
  73. ->select()
  74. ->toArray();
  75. }
  76. /**
  77. * @notes 获取数量
  78. * @return int
  79. * @author likeadmin
  80. * @date 2024/12/12 17:15
  81. */
  82. public function count(): int
  83. {
  84. return Labels::where($this->searchWhere)->where($this->queryDataWhere())->count();
  85. }
  86. }