<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Res\Web\Controller; use Illuminate\Support\Facades\Log; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\FileUtil; use ModStart\Core\Util\PageHtmlUtil; use ModStart\Module\ModuleBaseController; use Module\Member\Auth\MemberUser; use Module\Member\Util\MemberCreditUtil; use Module\Res\Type\ResAssetFileType; use Module\Res\Util\ResAssetUtil; class ResController extends ModuleBaseController { protected $api; public function __construct(\Module\Res\Api\Controller\ResController $pbQhK) { $this->api = $pbQhK; } public function lists($tKN9l = 0) { goto S0sgg; VxA0o: $U8wjN['categoryTree'] = Response::tryGetData($this->api->categories(), 'categoryTree'); goto iqpjL; UprEj: $U8wjN = Response::tryGetData($this->api->paginate()); goto VxA0o; iqpjL: $U8wjN['hottestAssets'] = Response::tryGetData($this->api->hottest(), 'records'); goto VOYvL; VOYvL: $U8wjN['pageHtml'] = PageHtmlUtil::render($U8wjN['total'], $U8wjN['pageSize'], $U8wjN['page'], '?' . Request::mergeQueries(array('page' => array('{page}')))); goto D3pT3; D3pT3: return $this->view('res.list', $U8wjN); goto OMGVx; S0sgg: InputPackage::mergeToInput('categoryId', $tKN9l); goto UprEj; OMGVx: } public function show($BW6Lj) { goto A0s6o; nI_Ee: return $this->view('res.show', $U8wjN); goto Kmdqj; Bpq0Y: InputPackage::mergeToInput('categoryId', $U8wjN['asset']['categoryId']); goto hsxFo; onZhM: $U8wjN['memberCreditTotal'] = MemberCreditUtil::getTotal(MemberUser::id()); goto Bpq0Y; A0s6o: InputPackage::mergeToInput('hash', $BW6Lj); goto Q96jR; Q96jR: try { $U8wjN = Response::tryGetData($this->api->get()); } catch (BizException $ZemkG) { if ('资源不存在' == $ZemkG->getMessage()) { return Response::page404(); } throw $ZemkG; } goto onZhM; hsxFo: $U8wjN['latestAssets'] = Response::tryGetData($this->api->latest(), 'records'); goto w93xX; w93xX: $U8wjN['recommendAssets'] = Response::tryGetData($this->api->recommends(), 'records'); goto nI_Ee; Kmdqj: } public function download($BW6Lj) { goto j3AzU; Z7vyv: switch ($U8wjN['fileType']) { case ResAssetFileType::FILE: goto fJazw; idrGi: Log::info('Res.ResController::download - ' . $EoIvR); goto MjOBn; fJazw: Log::info('Res.ResController::download - ' . json_encode($U8wjN, JSON_UNESCAPED_UNICODE)); goto QMfai; ufgfO: return Response::download($U8wjN['fileName'], FileUtil::safeGetContent($EoIvR)); goto q_5sY; QMfai: $EoIvR = FileUtil::savePathToLocalTemp($U8wjN['fileUrl'], null, true); goto idrGi; MjOBn: BizException::throwsIfEmpty('获取下载链接失败', $EoIvR); goto ufgfO; q_5sY: case ResAssetFileType::TEXT: return $this->view('res.download', $U8wjN); } goto D1SZ7; j3AzU: InputPackage::mergeToInput('hash', $BW6Lj); goto BodWV; BodWV: Log::info('Res.ResController::download - ' . $BW6Lj); goto Tvc34; Tvc34: $U8wjN = Response::tryGetData($this->api->download()); goto Z7vyv; D1SZ7: } public function downloadCredit($BW6Lj) { goto z0Z_k; ezL9e: BizException::throwsIfEmpty('获取下载链接失败', $EoIvR); goto W_VM1; z0Z_k: InputPackage::mergeToInput('hash', $BW6Lj); goto byZda; DE5EO: Log::info('Res.ResController::downloadCredit - ' . json_encode($U8wjN, JSON_UNESCAPED_UNICODE)); goto TXWl_; TXWl_: $EoIvR = FileUtil::savePathToLocalTemp($U8wjN['fileUrl'], null, true); goto WOGq1; W_VM1: return Response::download($U8wjN['fileName'], FileUtil::safeGetContent($EoIvR)); goto chx1z; i0sKU: $U8wjN = Response::tryGetData($this->api->downloadCredit()); goto DE5EO; byZda: Log::info('Res.ResController::downloadCredit - ' . $BW6Lj); goto i0sKU; WOGq1: Log::info('Res.ResController::downloadCredit - ' . $EoIvR); goto ezL9e; chx1z: } public function search() { goto Vz62w; Vz62w: $U8wjN = Response::tryGetData($this->api->paginate()); goto uWjwv; CSgXi: $U8wjN['pageHtml'] = PageHtmlUtil::render($U8wjN['total'], $U8wjN['pageSize'], $U8wjN['page'], '?' . Request::mergeQueries(array('page' => array('{page}')))); goto jt2p0; uWjwv: $U8wjN['categoryTree'] = Response::tryGetData($this->api->categories(), 'categoryTree'); goto JpT73; JpT73: $U8wjN['latestDocs'] = Response::tryGetData($this->api->latest(), 'records'); goto CSgXi; jt2p0: return $this->view('res.search', $U8wjN); goto SWjE8; SWjE8: } }