You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
	
	
		
		
			
	
    
		
			
				
					
						                                                    | 
						 | 
						<?php
namespace App\Admin\Repositories;use App\Models\AdminSetting;use Dcat\Admin\Grid;use Dcat\Admin\Repositories\Repository;use EasyWeChat\Factory;use GuzzleHttp\Exception\GuzzleException;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Facades\Cache;
/** * 小程序草稿箱 * Class MiniProgramDraft * @package App\Admin\Repositories */class MiniProgramList extends Repository{	protected $keyName = 'id';
	/**	 * 查询表格数据	 *	 * @param Grid\Model $model	 * @return LengthAwarePaginator	 * @throws GuzzleException	 */	public function get(Grid\Model $model): LengthAwarePaginator	{		$setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']);		$config = [			'app_id'   => $setting['service_appid'],			'secret'   => $setting['service_appsecret'],			'token'    => $setting['service_token'],			'aes_key'  => $setting['service_aeskey'],		];
		$cache_key = 'mini_program:list';		if ($data['subjects'] = Cache::get($cache_key)) {			$data['total'] = count($data['subjects']);		} else {			$openPlatform = Factory::openPlatform($config);			$codeTemplate = $openPlatform['code_template'];
			if (empty($codeTemplate) || (!$list = $openPlatform->getAuthorizers())) {				$data['total'] = 0;				$data['subjects'] = [];			} else {				$data['total'] = count($list['list']);				$data['subjects'] = $list['list'] ?? [];				Cache::put($cache_key, $list['list'], 120);			}		}
		return $model->makePaginator(			$data['total'] ?? 0, // 传入总记录数
			$data['subjects'] ?? [] // 传入数据二维数组
		);	}}
  |