| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\api\lists;
- use app\common\model\goods_category\GoodsCategory;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\reviews\GoodsReviews;
- /**
- * GoodsReviewsLists
- * Class GoodsReviewsLists
- * @package app\api\lists\GoodsReviewsLists
- */
- class GoodsReviewsLists extends BaseApiDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @date 2024/07/07 18:23
- */
- public function setSearch(): array
- {
- return [
- 'goods_id','user_id','review_status','goods_category_id'
- ];
- }
- public function queryWhere()
- {
- $where = [];
- $where[] = ['goods_category_id','=',!empty($this->params['category_id'])?$this->params['category_id']:'9999999'];
- $where[] = ['review_status','=',1];
- return $where;
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author whitef
- * @date 2024/07/07 18:23
- */
- public function lists(): array
- {
- $lists = GoodsReviews::where($this->searchWhere)
- ->where($this->queryWhere())
- ->limit($this->limitOffset, $this->limitLength)
- ->field(['id','nickname','avatar','rating','comment','review_image','create_time'])
- ->order('create_time desc')
- ->select()
- ->toArray();
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- * @author whitef
- * @date 2024/07/07 18:23
- */
- public function count(): int
- {
- return GoodsReviews::where($this->searchWhere)->where($this->queryWhere())->count();
- }
- }
|