Explorar el Código

Merge branch 'gq' of http://git.9026.com/roobe/miao

Mike hace 8 años
padre
commit
bc7ee19811

+ 2 - 1
server/app/Http/Controllers/Api/V1/AuthController.php

xqd
@@ -134,7 +134,8 @@ class AuthController extends Controller
      *    1104    LOGOUT_FAILED                   退出失败
      */
     public function logout() {
-        if (Auth::user()->token()->delete()) {
+        $user = Auth::user();
+        if ($user->token()->delete()) {
             return $this->api(['result' => true]);
         }
         return $this->error(ErrorCode::LOGOUT_FAILED);

+ 241 - 44
server/app/Http/Controllers/Api/V1/IndexController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -5,6 +5,8 @@ namespace App\Http\Controllers\Api\V1;
 use App\Models\BaseSettingsModel;
 use App\Models\DreamInfoModel;
 use App\Models\SearchInfoModel;
+use App\Models\UserCareUser;
+use App\Models\UserDream;
 use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
 use App\Services\Base\ErrorCode;
@@ -12,19 +14,33 @@ class IndexController extends Controller
 {
     /**
      * @api {get} /api/index/hot 热门(hot)
-     * @apiDescription 登陆(hot)
+     * @apiDescription 热门(hot)
      * @apiGroup Index
      * @apiPermission none
      * @apiVersion 0.1.0
-     * @apiParam {string}  phone   手机号码
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     * {
-     *     "state": true,
-     *     "code": 0,
-     *     "message": "",
-     *     "data": {
-     *         "verify_code": "1234"//该值调试时使用,sms调通后取消
+     *{
+     *"status": true,
+     *"status_code": 0,
+     *"message": "",
+     *"data": {
+     *      "banner": [],  轮播图
+     *      "other_user": [          动态用户
+     *                    'news_num':2    新消息数目
+     * ],
+     *      "dreams": [
+     *         "care_num": 0,   关注人数
+     *         "time": 1222222,   梦想倒计时
+     *         "dream_imgs_first": {
+     *               "pic": "",  梦想封面图片
+     *          }
+     *        "dream_find_user": [
+     *             {
+     *                  ...       发布梦想的用户信息
+     *            }
+     *         ],
+     *    ]
      *     }
      * }
      * @apiErrorExample {json} Error-Response:
@@ -35,8 +51,6 @@ class IndexController extends Controller
      *     "message": "传入参数不正确",
      *     "data": null or []
      * }
-     * 可能出现的错误代码:
-     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
      */
     public function hot(Request $request)
     {
@@ -44,13 +58,17 @@ class IndexController extends Controller
 //获取轮播图
         $banner = $this->getBanner();
 //        关注的用户
-       $other_user =  $user->UserCareUser;
+        $arr =  $user->UserCareUser;
+        $other_user = [] ;
+        foreach ($arr as $k => $v){
+            if ($v->pivot->dream_num > 0) {
+                $v->news_num = $v->pivot->dream_num;
+                $other_user[] = $v;
+            }
+        }
 //        获取其他用户信息 及梦想
         $dreams = DreamInfoModel::orderBy('score','desc')->limit(20)->get();
-        foreach ($dreams as $k => $dream) {
-            $dream->dream_find_user =  $dream->dreamFindUser;
-            $dream->dream_first_pic =  $dream->dreamImgsFirst;
-        }
+        $this->dreams($dreams);
         return $this->api(compact('banner','other_user','dreams'));
     }
 
@@ -60,15 +78,28 @@ class IndexController extends Controller
      * @apiGroup Index
      * @apiPermission none
      * @apiVersion 0.1.0
-     * @apiParam {string}  phone   手机号码
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     * {
-     *     "state": true,
-     *     "code": 0,
-     *     "message": "",
-     *     "data": {
-     *         "verify_code": "1234"//该值调试时使用,sms调通后取消
+     *{
+     *"status": true,
+     *"status_code": 0,
+     *"message": "",
+     *"data": {
+     *      "other_user": [   动态用户
+     *               'news_num':2    新消息数目
+     * ],
+     *      "dreams": [
+     *         "care_num": 0,   关注人数
+     *         "time": 1222222,   梦想倒计时
+     *         "dream_imgs_first": {
+     *               "pic": "",  梦想封面图片
+     *          }
+     *        "dream_find_user": [
+     *             {
+     *                  ...       发布梦想的用户信息
+     *            }
+     *         ],
+     *    ]
      *     }
      * }
      * @apiErrorExample {json} Error-Response:
@@ -79,20 +110,22 @@ class IndexController extends Controller
      *     "message": "传入参数不正确",
      *     "data": null or []
      * }
-     * 可能出现的错误代码:
-     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
      */
     public function trend(Request $request)
     {
         $user = $this->getUser();
 //        关注的用户
-        $other_user =  $user->UserCareUser;
+        $arr =  $user->UserCareUser;
+        $other_user = [] ;
+        foreach ($arr as $k => $v){
+            if ($v->pivot->dream_num > 0) {
+                $v->news_num = $v->pivot->dream_num;
+                $other_user[] = $v;
+            }
+        }
 //        获取其他用户信息 及梦想
         $dreams = DreamInfoModel::orderBy('score','desc')->offset(20)->limit(100)->get();
-        foreach ($dreams as $k => $dream) {
-            $dream->dream_find_user =  $dream->dreamFindUser;
-            $dream->dream_first_pic =  $dream->dreamImgsFirst;
-        }
+        $this->dreams($dreams);
         return $this->api(compact('other_user','dreams'));
     }
 
@@ -102,15 +135,28 @@ class IndexController extends Controller
      * @apiGroup Index
      * @apiPermission none
      * @apiVersion 0.1.0
-     * @apiParam {string}  phone   手机号码
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     * {
-     *     "state": true,
-     *     "code": 0,
-     *     "message": "",
-     *     "data": {
-     *         "verify_code": "1234"//该值调试时使用,sms调通后取消
+     *{
+     *"status": true,
+     *"status_code": 0,
+     *"message": "",
+     *"data": {
+     *      "other_user": [
+     *          'news_num':2    新消息数目
+     * ],  动态用户
+     *      "dreams": [
+     *         "care_num": 0,   关注人数
+     *         "time": 1222222,   梦想倒计时
+     *         "dream_imgs_first": {
+     *               "pic": "",  梦想封面图片
+     *          }
+     *        "dream_find_user": [
+     *             {
+     *                  ...       发布梦想的用户信息
+     *            }
+     *         ],
+     *    ]
      *     }
      * }
      * @apiErrorExample {json} Error-Response:
@@ -121,20 +167,22 @@ class IndexController extends Controller
      *     "message": "传入参数不正确",
      *     "data": null or []
      * }
-     * 可能出现的错误代码:
-     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
      */
     public function news(Request $request)
     {
         $user = $this->getUser();
 //        关注的用户
-        $other_user =  $user->UserCareUser;
+        $arr =  $user->UserCareUser;
+        $other_user = [] ;
+        foreach ($arr as $k => $v){
+            if ($v->pivot->dream_num > 0) {
+                $v->news_num = $v->pivot->dream_num;
+                $other_user[] = $v;
+            }
+        }
 //        获取其他用户信息 及梦想
         $dreams = DreamInfoModel::orderBy('score','desc')->offset(100)->limit(500)->get();
-        foreach ($dreams as $k => $dream) {
-            $dream->dream_find_user =  $dream->dreamFindUser;
-            $dream->dream_first_pic =  $dream->dreamImgsFirst;
-        }
+        $this->dreams($dreams);
         return $this->api(compact('other_user','dreams'));
     }
 
@@ -190,7 +238,7 @@ class IndexController extends Controller
         $data1 = UserInfoModel::where('nickname','like',$keyword)->get();
         $data2 = DreamInfoModel::where('dream','like',$keyword)->
             orWhere('dream','like',$keyword)->get();
-        $data3  = BaseSettingsModel::where('category','sign')->get();
+        $data3  = BaseSettingsModel::where('category','sign')->where('value','like',$keyword)->get();
         if (empty($request->keyword)) {
 //            历史搜索
                 $data1  = $user->search()->orderBy('id','desc')->limit(10)->get();
@@ -214,6 +262,85 @@ class IndexController extends Controller
         return $this->api(compact('data1','data2','data3'));
     }
 
+    /**
+     * @api {get}  /api/index/user_search 用户搜索(search)
+     * @apiDescription 用户搜索(search)
+     * @apiGroup Index
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {string}  keyword   关键字
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     *{
+     *    "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *  "data": {
+     *       "data1": [
+     *          "nickname": "ha",  昵称
+     *          "pic": "",    头像
+     *             ...
+     *       ]
+     *   }
+     *}
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     */
+    public function userSearch(Request $request)
+    {
+        if (empty($request->keyword)) {
+            return $this->api('');
+        }
+        $keyword ='%'.$request->keyword.'%';
+        $data1 = UserInfoModel::where('nickname','like',$keyword)->get();
+          return $this->api(compact('data1'));
+    }
+
+    /**
+     * @api {get}  /api/index/dream_search 梦想搜索(search)
+     * @apiDescription 梦想搜索(search)
+     * @apiGroup Index
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {string}  keyword   关键字
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+    {
+        "status": true,
+        "status_code": 0,
+        "message": "",
+        "data": {
+            "data": [
+                {
+                    "dream": "haha",  梦想名
+                    "user_pic": [
+                    {
+                        "pic": "",   用户头像
+                    }
+                    ],
+                    "dream_img": "",  梦想图片
+                }
+            ]
+        }
+    }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     */
+    public function dreamSearch(Request $request)
+    {
+        if (empty($request->keyword)) {
+            return $this->api('');
+        }
+        $keyword ='%'.$request->keyword.'%';
+        $data = DreamInfoModel::where('dream','like',$keyword)->
+        orWhere('dream','like',$keyword)->get();
+        foreach ($data as $k => $value) {
+            $value->user_pic = $value->dreamFindUser;
+            $value->dream_img = $value->dreamImgsFirst->pic;
+        }
+        return $this->api(compact('data'));
+    }
+
     //获取轮播图
     public function getBanner()
     {
@@ -221,4 +348,74 @@ class IndexController extends Controller
             ->orderBy('sort')->limit('3')->get()->toArray();
         return $banner;
     }
+
+//    完善梦想信息
+    public function dreams($dreams)
+    {
+        foreach ($dreams as $k => $dream) {
+            $dream->dream_find_user =  $dream->dreamFindUser;
+//            计算被关注总人数
+            $user_id = UserDream::where('dream_id',$dream->id)->first()->user_id;
+            $data = UserCareUser::where('other_user_id',$user_id)->get();
+            $dream->care_num = count($data);
+            $dream->dream_first_pic =  $dream->dreamImgsFirst;
+        }
+    }
+//    查看关注用户的最新动态
+    /**
+     * @api {get}  /api/index/news_info 关注用户动态详情
+     * @apiDescription 关注用户动态详情
+     * @apiGroup Index
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {int}  id   被点击用户ID
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+    {
+        "status": true,
+        "status_code": 0,
+        "message": "",
+        "data": [
+            {
+                "id": 12,
+                "dream": "123",
+                "about": "124",
+                "sign": null,
+                "videos": "234",
+                "money": 2345,
+                "time": 0,       倒计时 s
+                "get_money": 0,
+                "mark": 0,
+                "status": 0,
+                "score": 3,
+                "created_at": "2017-06-15 08:46:52",
+                "updated_at": "2017-06-15 08:46:52",
+                "deleted_at": null,
+                "imgs": [
+                    {
+                        "id": 8,
+                        "dream_id": 12,
+                        "title": "",
+                        "pic": "....png",   梦想图片
+                    },
+                ],
+            }
+        ]
+    }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     */
+    public function newsInfo(Request $request)
+    {
+//        查看后user_care_user dream_info 更新为零 首页不再显示
+        $user = $this->getUser();
+        $other_id = $request->id;
+        if (empty($other_id))  return $this->error(ErrorCode::MEMBER_NOT_EXIST);
+        UserCareUser::where('user_id',$user->id)->where('other_user_id',$other_id)->update(['dream_num'=>0]);
+        $data = UserInfoModel::find($other_id)->UserDream;
+        foreach ($data as $item) {
+            $item->imgs =  $item->dreamImgs ;
+        }
+        return $this->api($data);
+    }
 }

+ 66 - 334
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd
@@ -7,7 +7,9 @@ use App\Models\BaseSettingsModel;
 use App\Models\DreamImages;
 use App\Models\DreamInfoModel;
 use App\Models\ReplyCommentsInfo;
+use App\Models\UserCareUser;
 use App\Models\UserDream;
+use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
 use App\Services\Base\ErrorCode;
 class MyController extends Controller
@@ -119,376 +121,93 @@ class MyController extends Controller
     }
 
     /**
-     * @api {post} /api/my/nickname 修改昵称(nickname)
-     * @apiDescription 修改昵称(nickname)
+     * @api {get} /api/my/edit_user_info 修改个人信息
+     * @apiDescription 修改个人信息
      * @apiGroup My
-     * @apiParam {string} nickname 昵称
      * @apiPermission Passport
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     * {
-     *   " status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": ""
-    *}
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     * {
-     *   "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
-     *   "data": null
-     *  }
-     */
-    public function nickname(Request $request)
-    {
-        $user = $this->getUser();
-
-        $validator = \Validator::make($request->all(),
-            [
-                'nickname'  => 'required',
-            ],
-            [
-                'nickname.required'  => '昵称不能为空',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $nickname = $request->nickname;
-        $user->nickname = $nickname;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
-    }
-
-    /**
-     * @api {post} /api/my/sex 修改性别(sex get or post)
-     * @apiDescription 修改性别(sex)
-     * @apiGroup My
-     * @apiParam {sex} sex 性别
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * HTTP/1.1 200 OK
-     *   get
      *{
-     *   "status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": [
-     *       {
-     *           "value": "0",
-     *           "name": "男"
-     *       },
-     *       {
-     *          "value": "1",
-     *          "name": "女"
-     *       }
-     *    ]
-     *}
-     * post
-     * {
-     *   " status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": ""
-     *}
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     * {
-     *   "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
-     *   "data": null
-     *  }
-     */
-    public function sex(Request $request)
-    {
-        if ($request->method() == 'GET') {
-            $data = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
-                where('dictionary_code','sex')->get();
-            return $this->api($data);
-        }
-        $user = $this->getUser();
-
-        $validator = \Validator::make($request->all(),
-            [
-                'sex'  => 'required',
-            ],
-            [
-                'sex.required'  => '性别不能为空',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $sex = $request->sex;
-        $user->sex = $sex;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
-    }
-
-    /**
-     * @api {post} /api/my/signture 个性签名(signture)
-     * @apiDescription 个性签名(signture)
-     * @apiGroup My
-     * @apiParam {string} signture 个性签名
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * HTTP/1.1 200 OK
-     * {
-     *   " status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": ""
-     *}
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     * 保存
-     * {
-     *   "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
-     *   "data": null
-     *  }
-     * 提交
-     * {
-     *  "status": false,
-     *  "status_code": 1000,
-     *   "message": "个性签名不能为空",
-     *   "data": null
-     *}
-     */
-    public function signture(Request $request)
-    {
-        $user = $this->getUser();
-
-        $validator = \Validator::make($request->all(),
-            [
-                'signture'  => 'required',
-            ],
-            [
-                'signture.required'  => '个性签名不能为空',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $signture = $request->signture;
-        $user->signture = $signture;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
-    }
-
-    /**
-     * @api {post} /api/my/tel 修改手机号(tel)
-     * @apiDescription 修改手机号(tel)
-     * @apiGroup My
-     * @apiParam {int} tel 修改手机号
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * HTTP/1.1 200 OK
-     * {
-     *   " status": true,
+     *  "status": true,
      *   "status_code": 0,
      *   "message": "",
-     *   "data": ""
-     *}
+     *   "data": {
+     *       "emotion": [
+     *          {
+     *              "value": "1",
+     *              "name": "未婚"
+     *          },
+     *          ...
+     *      ],
+     *      "sex": [
+     *          {
+     *              "value": "0",
+     *              "name": "男"
+     *           },
+     *          ...
+     *      ]
+     *   }
+     * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      * {
      *   "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
+     *   "status_code": 1500,
+     *   "message": "会员不存在",
      *   "data": null
      *  }
      */
-    public function tel(Request $request)
+    public function  editUserInfo (Request $request)
     {
-        $user = $this->getUser();
+        $sex = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
+             where('dictionary_code','sex')->get();
+        $emotion = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
+             where('dictionary_code','emotion')->get();
 
-        $validator = \Validator::make($request->all(),
-            [
-                'tel'  => 'required|regex:/^1[34578][0-9]{9}$/',
-            ],
-            [
-                'tel.required'  => '手机号不能为空',
-                'tel.regex'  => '手机号格式不正确',
-            ]
-        );
+        return $this->api(compact('emotion','sex'));
 
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $tel = $request->tel;
-        $user->tel = $tel;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
     }
 
     /**
-     * @api {post} /api/my/job 工作类型(job  get or post)
-     * @apiDescription 工作类型(job)
+     * @api {post} /api/my/edit_user_info 保存个人信息
+     * @apiDescription   保存个人信息
+     *      @apiParam {string} pic   头像
+     *      @apiParam {int} sex   性别
+     *      @apiParam {string} signture   个性签名
+     *      @apiParam {int} emotion   情感状态
+     *      @apiParam {string} job   职业
+     *      @apiParam {int} tall   身高
      * @apiGroup My
-     * @apiParam {string} job 工作类型
      * @apiPermission Passport
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     * {
-     *   " status": true,
-     *   "status_code": 0,
+     *{
+     *    "status": true,
+     *    "status_code": 0,
      *   "message": "",
      *   "data": ""
      *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
-     * {
+     *{
      *   "status": false,
      *   "status_code": 600,
      *   "message": "保存用户数据失败",
      *   "data": null
-     *  }
+     * }
      */
-    public function job(Request $request)
+    public function updateUserInfo(Request $request)
     {
-        if ($request->method() == 'GET') {
-            $data = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
-            where('dictionary_code','job')->get();
-            return $this->api($data);
-        }
-
         $user = $this->getUser();
-
-        $validator = \Validator::make($request->all(),
-            [
-                'job'  => 'required',
-            ],
-            [
-                'job.required'  => '工作类型不能为空',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $job = $request->job;
-        $user->job = $job;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
-    }
-
-    /**
-     * @api {post} /api/my/job 情感状态(emotion  get or post)
-     * @apiDescription 情感状态(job)
-     * @apiGroup My
-     * @apiParam {int} emotion 情感状态
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * HTTP/1.1 200 OK
-     * {
-     *   " status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": ""
-     *}
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     * {
-     *   "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
-     *   "data": null
-     *  }
-     */
-    public function emotion(Request $request)
-    {
-        if ($request->method() == 'GET') {
-            $data = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
-            where('dictionary_code','emotion')->get();
-            return $this->api($data);
+        $data = $request->except('_token');
+        $ok =  $user->update($data);
+        if ($ok) {
+            return $this->api('');
+        }else{
+            return $this->error(ErrorCode::SAVE_USER_FAILED);
         }
-
-        $user = $this->getUser();
-
-        $validator = \Validator::make($request->all(),
-            [
-                'emotion'  => 'required',
-            ],
-            [
-                'emotion.required'  => '情感状态不能为空',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $emotion = $request->emotion;
-        $user->emotion = $emotion;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
-    }
-
-    /**
-     * @api {post} /api/my/tall 身高
-     * @apiDescription 身高
-     * @apiGroup My
-     * @apiParam {int} tall 身高
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * HTTP/1.1 200 OK
-     * {
-     *   " status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": ""
-     *}
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     * {
-     *   "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
-     *   "data": null
-     *  }
-     */
-    public function tall(Request $request)
-    {
-        $user = $this->getUser();
-
-        $validator = \Validator::make($request->all(),
-            [
-                'tall'  => 'required|integer',
-            ],
-            [
-                'tall.required'  => '身高不能为空',
-                'tall.integer'  => '身高只能填写数字',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-
-        $tall = $request->tall;
-        $user->tall = $tall;
-        $ok = $user->save();
-
-        if ($ok) return $this->api('');
-        return $this->error(ErrorCode::SAVE_USER_FAILED);
     }
 
     /**
@@ -791,21 +510,34 @@ class MyController extends Controller
         $a = $setting?$setting->key:1;
         $b = $setting?$setting->value:1;
         $t = 21*3600 / 60;
+
         $data = $request->except('_token','pics');
         \Log::debug(' care_num:'.$care_num.' a:'.$a.' b:'.$b.' t:'.$t);
-        $data['score'] = (log($care_num) + ($a/$t) + $b)*100000000 ;
+        if ($care_num == 0) {
+            $data['score'] = (($a/$t) + $b)*100000000 ;
+        }else{
+            $data['score'] = (log($care_num) + ($a/$t) + $b)*100000000 ;
+        }
         $data['created_at'] = date('Y-m-d H:i:s');
         $data['updated_at'] = date('Y-m-d H:i:s');
         $dream_id = DreamInfoModel::insertGetId($data);
 
         if ($dream_id) {
+//            梦想创建成功 关联关系中最新动态+1
+            $info = UserCareUser::where('other_user_id',$user->id)->get();
+            foreach ($info as $item) {
+                $item->dream_num += 1;
+                $item->updated_at = date('Y-m-d H:i:s');
+                $item->save();
+            }
+
             $data1['dream_id'] = $dream_id;
             $data1['user_id'] = $user->id;
             $data1['created_at'] = date('Y-m-d H:i:s');
             $data1['updated_at'] = date('Y-m-d H:i:s');
             $arr = $request->pics;
-            $videos = $request->videos;
-            if (empty($arr) && empty($videos))   return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
+            $video = $request->video;
+            if (empty($arr) && empty($video))   return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
             $ok = UserDream::create($data1);
             $arr1 = [];
             if ($ok) {

+ 1 - 1
server/app/Models/UserInfoModel.php

xqd
@@ -56,7 +56,7 @@ class UserInfoModel extends Authenticatable
 
     public function UserCareUser()
     {
-        return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id');
+        return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id')->withPivot('dream_num');
     }
 
 //    系统消息

+ 32 - 0
server/database/migrations/2017_06_20_135741_add_dream_num_to_user_care_user.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddDreamNumToUserCareUser extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('user_care_user', function (Blueprint $table) {
+            $table->integer('dream_num')->comment('被关注用户最新梦想数目')->default(0)->after('other_user_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('user_care_user', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 18 - 26
server/routes/api.php

xqd xqd
@@ -100,6 +100,18 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'index.search',
         'uses' => 'IndexController@search',
     ]);
+    $api->get('index/user_search', [
+        'as' => 'index.user_search',
+        'uses' => 'IndexController@userSearch',
+    ]);
+    $api->get('index/dream_search', [
+        'as' => 'index.dream_search',
+        'uses' => 'IndexController@dreamSearch',
+    ]);
+    $api->get('index/news_info', [
+        'as' => 'index.news_info',
+        'uses' => 'IndexController@newsInfo',
+    ]);
 
 //我的
     $api->get('my/index', [
@@ -110,33 +122,13 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.persona',
         'uses' => 'MyController@persona',
     ]);
-    $api->post('my/nickname', [
-        'as' => 'my.nickname',
-        'uses' => 'MyController@nickname',
-    ]);
-    $api->any('my/sex', [
-        'as' => 'my.sex',
-        'uses' => 'MyController@sex',
-    ]);
-    $api->post('my/signture', [
-        'as' => 'my.signture',
-        'uses' => 'MyController@signture',
-    ]);
-    $api->post('my/tel', [
-        'as' => 'my.tel',
-        'uses' => 'MyController@tel',
-    ]);
-    $api->any('my/job', [
-        'as' => 'my.job',
-        'uses' => 'MyController@job',
-    ]);
-    $api->any('my/emotion', [
-        'as' => 'my.emotion',
-        'uses' => 'MyController@emotion',
+    $api->get('my/edit_user_info', [
+        'as' => 'my.edit_user_info',
+        'uses' => 'MyController@editUserInfo',
     ]);
-    $api->post('my/tall', [
-        'as' => 'my.tall',
-        'uses' => 'MyController@tall',
+    $api->post('my/update_user_info', [
+        'as' => 'my.update_user_info',
+        'uses' => 'MyController@updateUserInfo',
     ]);
 //    充值
     $api->get('my/recharge', [