| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\workerapi\lists;
- use app\common\model\fault_code\FaultCode;
- use app\common\lists\ListsSearchInterface;
- /**
- * FaultCode列表
- * Class FaultSearchLists
- */
- class FaultSearchLists extends BaseWorkerDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/10/18 09:58
- */
- public function setSearch(): array
- {
- return [
- ];
- }
- /*
- * 查询条件
- * @return array
- */
- public function queryWhere(){
-
- $where[] = ['a.status', '=', 1];
- if (!empty($this->params['keyword'])) {
- $where[] = ['a.name', 'like', '%'.$this->params['keyword'].'%'];
- }
- if (!empty($this->params['goods_category_id'])) {
- $where[] = ['b.goods_category_id', '=', $this->params['goods_category_id']];
- } else {
- $where[] = ['b.goods_category_id', '=', 0];
- }
- return $where;
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/10/18 09:58
- */
- public function lists(): array
- {
- $lists = FaultCode::alias("a")
- ->with(['firstType'])
- ->leftJoin('fault_type b', 'a.type_id = b.id')
- ->where($this->queryWhere())
- ->field('a.id,a.name,a.price,b.id as pre_id ,b.name as pre_name, b.pid')
- ->limit($this->limitOffset, $this->limitLength)
- ->select()
- ->toArray();
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/10/18 09:58
- */
- public function count(): int
- {
- return FaultCode::alias("a")
- ->leftJoin('fault_type b', 'a.type_id = b.id')
- ->where($this->queryWhere())
- ->count();
- }
- }
|