FaultSearchLists.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\workerapi\lists;
  15. use app\common\model\fault_code\FaultCode;
  16. use app\common\lists\ListsSearchInterface;
  17. /**
  18. * FaultCode列表
  19. * Class FaultSearchLists
  20. */
  21. class FaultSearchLists extends BaseWorkerDataLists implements ListsSearchInterface
  22. {
  23. /**
  24. * @notes 设置搜索条件
  25. * @return \string[][]
  26. * @author likeadmin
  27. * @date 2024/10/18 09:58
  28. */
  29. public function setSearch(): array
  30. {
  31. return [
  32. ];
  33. }
  34. /*
  35. * 查询条件
  36. * @return array
  37. */
  38. public function queryWhere(){
  39. $where[] = ['a.status', '=', 1];
  40. if (!empty($this->params['keyword'])) {
  41. $where[] = ['a.name', 'like', '%'.$this->params['keyword'].'%'];
  42. }
  43. if (!empty($this->params['goods_category_id'])) {
  44. $where[] = ['b.goods_category_id', '=', $this->params['goods_category_id']];
  45. } else {
  46. $where[] = ['b.goods_category_id', '=', 0];
  47. }
  48. return $where;
  49. }
  50. /**
  51. * @notes 获取列表
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @author likeadmin
  57. * @date 2024/10/18 09:58
  58. */
  59. public function lists(): array
  60. {
  61. $lists = FaultCode::alias("a")
  62. ->with(['firstType'])
  63. ->leftJoin('fault_type b', 'a.type_id = b.id')
  64. ->where($this->queryWhere())
  65. ->field('a.id,a.name,a.price,b.id as pre_id ,b.name as pre_name, b.pid')
  66. ->limit($this->limitOffset, $this->limitLength)
  67. ->select()
  68. ->toArray();
  69. return $lists;
  70. }
  71. /**
  72. * @notes 获取数量
  73. * @return int
  74. * @author likeadmin
  75. * @date 2024/10/18 09:58
  76. */
  77. public function count(): int
  78. {
  79. return FaultCode::alias("a")
  80. ->leftJoin('fault_type b', 'a.type_id = b.id')
  81. ->where($this->queryWhere())
  82. ->count();
  83. }
  84. }