initModel($modelOrRelations); $distInfo = DistAdminDistributor::getInfo(); //可查看的相册目录 $albumFolder = empty($distInfo->album_folder) ? [] : json_decode($distInfo->album_folder); $this->albumFolder = $albumFolder; } /* * 执行RPC调用 */ public function execute($method, $params = []) { return RpcClient::albumExecute($method, $params); } /* * 通过IDS获取相册详情 */ public function getByids($ids) { return $this->execute('siteAlbumGetByIds', [ 'ids' => $ids, ]); } /* * 获取相册列表 */ public function get(Grid\Model|\Dcat\Admin\Grid\Model $model) { $self = new self(); // 获取当前页数 $currentPage = $model->getCurrentPage(); // 获取每页显示行数 $perPage = $model->getPerPage(); //排序 $sort = $model->getSort(); if (empty($sort) == true || $sort[0] == null) { $sort = []; } // 获取筛选参数 $filterModel = $model->filter()->input('model', ''); $folder_id = $model->filter()->input('folder_id', ''); $filter = [ 'model' => $filterModel, 'folder_id' => $folder_id, 'album_folder' => $self->albumFolder,//把查询结果限定在album_folder中 ]; $result = $this->execute('siteAlbumPaginate', [ 'filter' => $filter, 'sort' => $sort, 'perPage'=>$perPage, 'page' => $currentPage, ]); $data = $result['data'] ?? []; return $model->makePaginator( $data['total'] ?? 0, $data['data'] ?? [] // 传入数据二维数组 ); } /* * 获取相册详情 */ public function detail(Show $show): array { // 获取数据主键值 $id = $show->getKey(); $result = $this->execute('siteAlbumGet', [ 'id' => $id, ]); $data = $result['data'] ?? []; return $data; } }