CompanyController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace App\Http\Controllers\Api\V1;
  3. use App\Models\SwCompanyInfoModel;
  4. use Illuminate\Http\Request;
  5. use Validator;
  6. use App\Services\Base\ErrorCode;
  7. class CompanyController extends Controller
  8. {
  9. /**
  10. * @api {get} /api/company/info 公司详情(info)
  11. * @apiDescription 公司详情(info)
  12. * @apiGroup Company
  13. * @apiPermission none
  14. * @apiVersion 0.1.0
  15. * @apiParam {string} appid appid
  16. * @apiSuccessExample {json} Success-Response:
  17. * HTTP/1.1 200 OK
  18. * {
  19. * "state": true,
  20. * "code": 0,
  21. * "message": "",
  22. * "data": {
  23. * "info": []//公司详情
  24. * }
  25. * }
  26. * @apiErrorExample {json} Error-Response:
  27. * HTTP/1.1 400 Bad Request
  28. * {
  29. * "state": false,
  30. * "code": 1000,
  31. * "message": "传入参数不正确",
  32. * "data": null or []
  33. * }
  34. * 可能出现的错误代码:
  35. * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
  36. */
  37. public function companyInfo(Request $request){
  38. $validator = Validator::make($request->all(), [
  39. 'appid' => 'required',
  40. ], [
  41. 'appid.required' => 'appid未知',
  42. ]);
  43. if ($validator->fails()) {
  44. return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
  45. }
  46. $info = SwCompanyInfoModel::where('appid',$request->appid)->first();
  47. if (!$info) return $this->error(1000,'信息不存在');
  48. if ($info->show) $info->show = explode(',',$info->show);
  49. if ($info->pic) $info->pic = explode(',',$info->pic);
  50. return $this->api(compact('info'));
  51. }
  52. /**
  53. * @api {get} /api/agent/version 获取配置信息(version)
  54. * @apiDescription 获取配置信息(version)
  55. * @apiGroup Agent
  56. * @apiPermission Passport
  57. * @apiVersion 0.1.0
  58. * @apiSuccessExample {json} Success-Response:
  59. * HTTP/1.1 200 OK
  60. * {
  61. * "state": true,
  62. * "code": 0,
  63. * "message": "",
  64. * "data": {
  65. * "version": []版本信息
  66. * }
  67. * }
  68. * @apiErrorExample {json} Error-Response:
  69. * HTTP/1.1 400 Bad Request
  70. * 可能出现的错误代码:
  71. * 1000 运营商非法
  72. */
  73. public function version()
  74. {
  75. $version = config('version.version');
  76. if (!$version) $version = [];
  77. return $this->api(compact('version'));
  78. }
  79. }