1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Http\Controllers\Api\V1;
- use App\Models\SwCompanyInfoModel;
- use Illuminate\Http\Request;
- use Validator;
- use App\Services\Base\ErrorCode;
- class CompanyController extends Controller
- {
- /**
- * @api {get} /api/company/info 公司详情(info)
- * @apiDescription 公司详情(info)
- * @apiGroup Company
- * @apiPermission none
- * @apiVersion 0.1.0
- * @apiParam {string} appid appid
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- * {
- * "state": true,
- * "code": 0,
- * "message": "",
- * "data": {
- * "info": []//公司详情
- * }
- * }
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- * {
- * "state": false,
- * "code": 1000,
- * "message": "传入参数不正确",
- * "data": null or []
- * }
- * 可能出现的错误代码:
- * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
- */
- public function companyInfo(Request $request){
- $validator = Validator::make($request->all(), [
- 'appid' => 'required',
- ], [
- 'appid.required' => 'appid未知',
- ]);
- if ($validator->fails()) {
- return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
- }
- $info = SwCompanyInfoModel::where('appid',$request->appid)->first();
- if (!$info) return $this->error(1000,'信息不存在');
- if ($info->show) $info->show = explode(',',$info->show);
- if ($info->pic) $info->pic = explode(',',$info->pic);
- return $this->api(compact('info'));
- }
- /**
- * @api {get} /api/agent/version 获取配置信息(version)
- * @apiDescription 获取配置信息(version)
- * @apiGroup Agent
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- * {
- * "state": true,
- * "code": 0,
- * "message": "",
- * "data": {
- * "version": []版本信息
- * }
- * }
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- * 可能出现的错误代码:
- * 1000 运营商非法
- */
- public function version()
- {
- $version = config('version.version');
- if (!$version) $version = [];
- return $this->api(compact('version'));
- }
- }
|