| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\workerapi\lists;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\spare_part\SparePart;
- /**
- * SparePart列表
- * Class SparePartLists
- * @package app\workerapi\lists
- */
- class SparePartLists extends BaseWorkerDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function setSearch(): array
- {
- $this->params['spare_status'] = 1;
- return [
- '=' => ['spare_status'],
- '%like%' => ['spare_name']
- ];
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function lists(): array
- {
- return SparePart::where($this->searchWhere)
- ->field(['id', 'goods_category_id', 'spare_name', 'spare_image', 'spare_number', 'spare_unit', 'company_price', 'original_price', 'offering_price', 'spare_status'])
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function count(): int
- {
- return SparePart::where($this->searchWhere)->count();
- }
- }
|