wesley.chen il y a 7 ans
Parent
commit
9ecaf6a7ec

+ 25 - 4
app/Http/Controllers/Api/V1/HomeController.php

xqd xqd xqd xqd
@@ -179,11 +179,12 @@ class HomeController extends Controller
 
 
     /**
-     * @api {get} /api/home/getbasedata   获取可选批次及省份
-     * @apiDescription 获取可选批次及省份
+     * @api {post} /api/home/getbasedata   获取可基础数据
+     * @apiDescription 获取基础数据
      * @apiGroup 高考助手
      * @apiPermission none
      * @apiVersion 0.1.0
+     * @apiParam {int}    [userid]   用户ID(必填)
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
@@ -191,6 +192,9 @@ class HomeController extends Controller
      *     "status_code": 0,
      *     "message": "",
      *     "data": {
+     *         "userinfo":[
+     *
+     *          ]
      *         "batchs": [
      *
      *          ],
@@ -211,15 +215,31 @@ class HomeController extends Controller
      * 可能出现的错误代码:
      *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
      */
-    public function getBaseData()
+    public function getBaseData(Request $request)
     {
+        $validator = Validator::make($request->all(),
+            [
+                'userid' => 'required',
+            ],
+            [
+                'userid.required' => 'userid不能为空!',
+            ]
+        );
+
+
+        if ($validator->fails()) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
+        }
+
         $batchs = MajorInfoModel::groupBy('batch')->pluck('batch');
 
         $provinces = [
             "全部省份", "安徽", "澳门", "北京", "重庆", "福建", "甘肃", "广东", "广西", "贵州", "海南", "河北", "河南", "黑龙江", "湖北", "湖南", "吉林", "江苏", "江西", "辽宁", "内蒙古", "宁夏", "青海", "山东", "山西", "陕西", "上海", "四川", "台湾", "天津", "西藏", "香港", "新疆", "云南", "浙江"
         ];
 
-        return $this->api(compact('batchs', 'provinces'));
+        $userinfo = UserInfoModel::select(['id','username','code','cnumber','class','grade','mobile'])->find(request('userid'));
+
+        return $this->api(compact('userinfo','batchs', 'provinces'));
     }
 
 
@@ -605,6 +625,7 @@ class HomeController extends Controller
         $data['mobile'] = request('mobile');
         $data['grade'] = request('grade');
         $data['code'] = request('code');
+        $data['class'] = request('class');
 
         $res = UserInfoModel::where('id', $userid)->update($data);
 

+ 30 - 17
public/apidoc/api_data.js

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -149,9 +149,9 @@ define({ "api": [
   },
   {
     "type": "get",
-    "url": "/api/home/getbasedata",
-    "title": "获取可选批次及省份",
-    "description": "<p>获取可选批次及省份</p>",
+    "url": "/api/home/getintroduction",
+    "title": "获取使用说用及协议",
+    "description": "<p>获取使用说用及协议</p>",
     "group": "____",
     "permission": [
       {
@@ -163,7 +163,7 @@ define({ "api": [
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"batchs\": [\n\n         ],\n         \"provinces\":[\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"list\": [\n\n         ]\n\n    }\n}",
           "type": "json"
         }
       ]
@@ -179,13 +179,13 @@ define({ "api": [
     },
     "filename": "app/Http/Controllers/Api/V1/HomeController.php",
     "groupTitle": "____",
-    "name": "GetApiHomeGetbasedata"
+    "name": "GetApiHomeGetintroduction"
   },
   {
-    "type": "get",
-    "url": "/api/home/getintroduction",
-    "title": "获取使用说用及协议",
-    "description": "<p>获取使用说用及协议</p>",
+    "type": "post",
+    "url": "/api/home/agreeintroduction",
+    "title": "同意使用说用及协议",
+    "description": "<p>同意使用说用及协议</p>",
     "group": "____",
     "permission": [
       {
@@ -193,11 +193,24 @@ define({ "api": [
       }
     ],
     "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "userid",
+            "description": "<p>用户ID(必填)</p>"
+          }
+        ]
+      }
+    },
     "success": {
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"list\": [\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"userinfo\": [\n\n         ]\n\n    }\n}",
           "type": "json"
         }
       ]
@@ -213,13 +226,13 @@ define({ "api": [
     },
     "filename": "app/Http/Controllers/Api/V1/HomeController.php",
     "groupTitle": "____",
-    "name": "GetApiHomeGetintroduction"
+    "name": "PostApiHomeAgreeintroduction"
   },
   {
     "type": "post",
-    "url": "/api/home/agreeintroduction",
-    "title": "同意使用说用及协议",
-    "description": "<p>同意使用说用及协议</p>",
+    "url": "/api/home/getbasedata",
+    "title": "获取可基础数据",
+    "description": "<p>获取基础数据</p>",
     "group": "____",
     "permission": [
       {
@@ -244,7 +257,7 @@ define({ "api": [
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"userinfo\": [\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"userinfo\":[\n\n         ]\n        \"batchs\": [\n\n         ],\n         \"provinces\":[\n\n         ]\n\n    }\n}",
           "type": "json"
         }
       ]
@@ -260,7 +273,7 @@ define({ "api": [
     },
     "filename": "app/Http/Controllers/Api/V1/HomeController.php",
     "groupTitle": "____",
-    "name": "PostApiHomeAgreeintroduction"
+    "name": "PostApiHomeGetbasedata"
   },
   {
     "type": "post",
@@ -380,7 +393,7 @@ define({ "api": [
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"decryptedData\": [\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"decryptedData\": [\n\n         ]\n\n    }\n\n}",
           "type": "json"
         }
       ]

+ 30 - 17
public/apidoc/api_data.json

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -149,9 +149,9 @@
   },
   {
     "type": "get",
-    "url": "/api/home/getbasedata",
-    "title": "获取可选批次及省份",
-    "description": "<p>获取可选批次及省份</p>",
+    "url": "/api/home/getintroduction",
+    "title": "获取使用说用及协议",
+    "description": "<p>获取使用说用及协议</p>",
     "group": "____",
     "permission": [
       {
@@ -163,7 +163,7 @@
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"batchs\": [\n\n         ],\n         \"provinces\":[\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"list\": [\n\n         ]\n\n    }\n}",
           "type": "json"
         }
       ]
@@ -179,13 +179,13 @@
     },
     "filename": "app/Http/Controllers/Api/V1/HomeController.php",
     "groupTitle": "____",
-    "name": "GetApiHomeGetbasedata"
+    "name": "GetApiHomeGetintroduction"
   },
   {
-    "type": "get",
-    "url": "/api/home/getintroduction",
-    "title": "获取使用说用及协议",
-    "description": "<p>获取使用说用及协议</p>",
+    "type": "post",
+    "url": "/api/home/agreeintroduction",
+    "title": "同意使用说用及协议",
+    "description": "<p>同意使用说用及协议</p>",
     "group": "____",
     "permission": [
       {
@@ -193,11 +193,24 @@
       }
     ],
     "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "userid",
+            "description": "<p>用户ID(必填)</p>"
+          }
+        ]
+      }
+    },
     "success": {
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"list\": [\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"userinfo\": [\n\n         ]\n\n    }\n}",
           "type": "json"
         }
       ]
@@ -213,13 +226,13 @@
     },
     "filename": "app/Http/Controllers/Api/V1/HomeController.php",
     "groupTitle": "____",
-    "name": "GetApiHomeGetintroduction"
+    "name": "PostApiHomeAgreeintroduction"
   },
   {
     "type": "post",
-    "url": "/api/home/agreeintroduction",
-    "title": "同意使用说用及协议",
-    "description": "<p>同意使用说用及协议</p>",
+    "url": "/api/home/getbasedata",
+    "title": "获取可基础数据",
+    "description": "<p>获取基础数据</p>",
     "group": "____",
     "permission": [
       {
@@ -244,7 +257,7 @@
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"userinfo\": [\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"userinfo\":[\n\n         ]\n        \"batchs\": [\n\n         ],\n         \"provinces\":[\n\n         ]\n\n    }\n}",
           "type": "json"
         }
       ]
@@ -260,7 +273,7 @@
     },
     "filename": "app/Http/Controllers/Api/V1/HomeController.php",
     "groupTitle": "____",
-    "name": "PostApiHomeAgreeintroduction"
+    "name": "PostApiHomeGetbasedata"
   },
   {
     "type": "post",
@@ -380,7 +393,7 @@
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"decryptedData\": [\n\n         ]\n\n    }\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"decryptedData\": [\n\n         ]\n\n    }\n\n}",
           "type": "json"
         }
       ]

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -7,7 +7,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-06-11T07:36:04.696Z",
+    "time": "2018-06-12T02:48:44.317Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 1 - 1
public/apidoc/api_project.json

xqd
@@ -7,7 +7,7 @@
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-06-11T07:36:04.696Z",
+    "time": "2018-06-12T02:48:44.317Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 1 - 1
routes/api.php

xqd
@@ -69,7 +69,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'uses' => 'HomeController@getIntroduction',
     ]);
 
-    $api->get('home/getbasedata', [
+    $api->post('home/getbasedata', [
         'as' => 'home.getbasedata',
         'uses' => 'HomeController@getBaseData',
     ]);