1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace App\Admin\Repositories;
- use App\Libraries\RpcClient;
- use App\Models\NullModel as Model;
- use Dcat\Admin\Form;
- use Dcat\Admin\Repositories\EloquentRepository;
- use Dcat\Admin\Show;
- use JsonRPC\Client;
- /*
- * RPC调用相册
- */
- class RpcAlbum extends EloquentRepository
- {
- /**
- * Model.
- *
- * @var string
- */
- protected $eloquentClass = Model::class;
- 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)
- {
- // 获取当前页数
- $currentPage = $model->getCurrentPage();
- // 获取每页显示行数
- $perPage = $model->getPerPage();
- // 获取筛选参数
- $filterModel = $model->filter()->input('model', '');
- $folder_id = $model->filter()->input('folder_id', '');
- $filter = [
- 'model' => $filterModel,
- 'folder_id' => $folder_id,
- ];
- $result = $this->execute('siteAlbumPaginate', [
- 'filter' => $filter,
- '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;
- }
- }
|