123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Distributor\Repositories;
- use App\Libraries\RpcClient;
- use App\Models\NullModel as Model;
- use Dcat\Admin\Repositories\EloquentRepository;
- use Dcat\Admin\Show;
- /*
- * RPC调用相册
- */
- class RpcAlbumFolder extends EloquentRepository
- {
- /**
- * Model.
- *
- * @var string
- */
- protected $eloquentClass = Model::class;
- public $albumFolder = [];
- public function __construct($modelOrRelations = [])
- {
- $this->initModel($modelOrRelations);
- $distInfo = DistAdminDistributor::getInfo();
- $albumFolder = empty($distInfo->album_folder) ? [] : json_decode($distInfo->album_folder,true);
- $this->albumFolder = $albumFolder;
- }
- /*
- * RPC调用
- */
- public function execute($method, $params = [])
- {
- return RpcClient::albumExecute($method, $params);
- }
- /*
- * 获取相册文件夹列表
- * $inIds 传入的相册ID数组,为空时获取全部相册
- */
- public static function selectOptions($lang = 'en') {
- $self = new self();
- $inIds = $self->albumFolder;
- if ($lang == 'en') {
- $result = $self->execute('siteAlbumFolderSelectOptionsEn', ['inIds' => $inIds]);
- } else {
- $result = $self->execute('siteAlbumFolderSelectOptions', ['inIds' => $inIds]);
- }
- $data = $result['data'] ?? [];
- return $data;
- }
- /*
- * 得到相册文件夹树全部节点
- */
- public static function siteAlbumFolderAllNodes() {
- $self = new self();
- $inIds = $self->albumFolder;
- $result = $self->execute('siteAlbumFolderAllNodes', []);
- $data = $result['data'] ?? [];
- foreach ($data as $key => $value) {
- //id或parent_id为都不在$inIds的节点,删除
- if (!in_array($value['id'], $inIds) && !in_array($value['parent_id'], $inIds)) {
- unset($data[$key]);
- }
- }
- return $data;
- }
- }
|