| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Http\Validator\AgentValidator;
- use App\Services\Api\AgentService;
- /**
- * 代理
- * @package App\Http\Controllers\Api
- */
- class AgentController extends webApp
- {
- /**
- * 列表
- * @return array
- */
- public function index()
- {
- $params =request()->post();
- $pageSize = request()->post('pageSize', 15);
- $datas = AgentService::make()->getDataList($params, $pageSize);
- return showJson(1010, true, $datas);
- }
- /**
- * 详情
- * @return array
- */
- public function info()
- {
- try {
- if(!$result = AgentService::make()->getInfo($this->userId)){
- return showJson(1009, false);
- }else{
- return showJson(1010, true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 入驻
- * @param AgentValidator $validator
- * @return array
- */
- public function apply(AgentValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'apply');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- try {
- if(!$result = AgentService::make()->apply($this->userId, $params)){
- return showJson(AgentService::make()->getError(), false);
- }else{
- return showJson(AgentService::make()->getError(), true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- }
|