gq 8 年之前
父節點
當前提交
f87efa7c71

+ 198 - 198
server/app/Http/Controllers/Api/V1/DreamController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api\V1;
 
 use App\Models\AccountLog;
 use App\Models\BaseSettingsModel;
+use App\Models\CommentsInfoModel;
 use App\Models\DreamImages;
 use App\Models\DreamInfoModel;
 use App\Models\InteractionInfo;
@@ -23,107 +24,82 @@ class DreamController extends Controller
      * @apiGroup Dream
      * @apiPermission Passport
      * @apiVersion 0.1.0
-     * @apiParam {int} type home interaction paihang  默认all
+     * @apiParam {int} type home interaction paihang  默认home
      * @apiParam {int} id 梦想ID
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      *               主页
-     *{
-     *   "status": true,
-     *  "status_code": 0,
-     *  "message": "",
-     *      "data": {
-     *      "dream": {                          梦想
-     *          "id": 7,
-     *          "user_id": 2,
-     *          "dream": "梦想标1123",
-     *          "about": "梦想烧1111213",
-     *          "video": "",
-     *          "sign": null,
-     *          "money": 10000,
-     *          "time": 720000,
-     *          "get_money": 0,
-     *          "status": 0,
-     *          "updated_at": "2017-06-22 09:47:03"
-     *     },
-     *      "imgs": [                          梦想图片
-     *          {
-     *              "title": "",
-     *              "pic": "http://w17.9026.com/img/banner/banner_3.png"
-     *         },
-     *          {
-     *               "title": "",
-     *              "pic": "http://w17.9026.com/img/banner/banner_3.png"
-     *          }
-     *     ],
-     *      "arr": {                            支持者前三(user_id和头像)
-     *         "6": "http://www.wsfjq.com/photos/bd119684755.jpg",
-     *           "1": "http://www.wsfjq.com/photos/bd119684755.jpg"
-     *      }
-     *       "money" : "1000"    用户余额
-     *       "score" : "1000"    梦想分数
-     *      "a": "0.001",   支持乘数计算  y = -a * b +c   b = updated_at-当前时间  (分钟)   y>=1
-     *      "c": "8"
-     *  }
-     *}
-     *          排行
-     *{
-     *   "status": true,
-     *  "status_code": 0,
-     *   "message": "",
-     *  "data": [
-     *      {
-     *          "nickname": "ha",      昵称
-     *          "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",     头像
-     *          "score": 112000                        支持分
-     *      },
-     *  ]
-     *}
-     *     互动
-     *{
-     *   "status": true,
-     *  "status_code": 0,
-     *  "message": "",
-     *  "data": {
-     *       "data": [
-     *           {
-     *          "id": 7,
-     *          "dream_id": 2,
-     *          "title": "梦想动态有力来了",
-     *          "pic1": "http\"//www.baidu.com",
-     *          "created_at": "2017-06-22 21:09:18",
-     *          "updated_at": "2017-06-22 21:09:18",
-     *          "deleted_at": null,
-     *          "comments": [                          评论
-     *              {
-     *                  "interaction_id": 7,
-     *                  "user_id": 1,
-     *                  "level": 0,
-     *                  "content": "不错的梦想",
-     *                  "updated_at": null,
-     *                 "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",    评论者头像
-     *                 "replay": [                                     回复
-     *                  {
-     *                      "user_id": 1,
-     *                      "level": 0,
-     *                      "content": "我也觉得不错",
-     *                     "updated_at": null,
-     *                     "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"       回复者头像
-     *                  },
-     *                  {
-     *                      "user_id": 6,
-     *                       "level": 0,
-     *                      "content": "祝你梦想成真",
-     *                      "updated_at": null,
-     *                      "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
-     *                  }
-     *              }
-     *          ]
-     *       ]
-     *  },
-     *  "times": 720000                    梦想实现倒计时(s)
-     *  }
-     *}
+    {
+        "status": true,
+        "status_code": 0,
+        "message": "",
+        "data": {
+            "dream": {                             梦想
+                "id": 4,
+                "user_id": 1,
+                "name": "梦想标题1",
+                "about": "梦想介绍",
+                "coin": 2500,
+                "time": 21,
+                "get_coin": 600,
+                "status": 0,
+                "video": null,
+                "score": 100079365,
+                "sign": "",
+                "created_at": "2017-06-25 11:47:45",
+                "updated_at": "2017-06-25 15:10:50",
+                "imgs": [                          梦想图片
+                    {
+                        "title": "",
+                        "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1498372396639&di=43f031aa703d741f2adbd0e6a501aaaf&imgtype=0&src=http%3A%2F%2Fimg2.touxiang.cn%2Ffile%2F20170524%2Feaca9092ca852e6e9c6ec46b7b14f12f.jpg"
+                    },
+                    {
+                        "title": "",
+                        "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1498372396639&di=43f031aa703d741f2adbd0e6a501aaaf&imgtype=0&src=http%3A%2F%2Fimg2.touxiang.cn%2Ffile%2F20170524%2Feaca9092ca852e6e9c6ec46b7b14f12f.jpg"
+                    },
+                    {
+                        "title": "",
+                        "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1498372396639&di=43f031aa703d741f2adbd0e6a501aaaf&imgtype=0&src=http%3A%2F%2Fimg2.touxiang.cn%2Ffile%2F20170524%2Feaca9092ca852e6e9c6ec46b7b14f12f.jpg"
+                    }
+                ],
+                "user": {                            梦想用户
+                    "id": 1,
+                    "phone": "13880642880",
+                    "nickname": "name1",
+                    "avatar": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1498379352960&di=0e62b422eb24482043701a568fb290d8&imgtype=0&src=http%3A%2F%2Fimg5.duitang.com%2Fuploads%2Fitem%2F201507%2F14%2F20150714130925_kzrcM.thumb.224_0.jpeg",
+                    "birthday": "2000-06-21",
+                    "sign": 0,
+                    "money": 0,
+                    "coin": 1300,
+                    "sex": 1,
+                    "signture": "",
+                    "height": 170,
+                    "work": "",
+                    "emotion": 1,
+                    "address": "",
+                    "city": "",
+                    "detail_address": "",
+                    "status": 1,
+                    "wechat": "",
+                    "weibo": "",
+                    "remember_token": "",
+                    "created_at": "2017-06-25 10:27:08",
+                    "updated_at": "2017-06-25 15:20:11",
+                    "deleted_at": null
+                }
+            },
+            "top3user": [                              支持者前三
+                {
+                    "id": 2,
+                    "phone": "13880642881",
+                    "nickname": "name2",
+                    "avatar": "https://timgsa.baidu.com/timg?imamb.224_0.jpeg",
+                    "score": 2399
+                }
+            ],
+            "number": 1                                支持乘数
+        }
+    }
      * @apiErrorExample {json} Error-Response:
      *HTTP/1.1 400 Bad Request
      *{
@@ -135,7 +111,6 @@ class DreamController extends Controller
      */
     public function show(Request $request)
     {
-        $user = $this->getUser();
         $type = $request->type;    //类型
         $id = $request->id;    //梦想ID
         if (empty($id)) return $this->error(ErrorCode::KEY_ERROR);
@@ -156,49 +131,35 @@ class DreamController extends Controller
             $user = UserInfoModel::find($user_id);
             $user->score = $score;
             $topuser[] = $user;
-            if(count($top3user)<=2) $top3user[] = $user;
+            if(count($top3user) <= 2) $top3user[] = $user ;
         }
         if ($type == 'paihang') return $this->api($topuser);
-
         $interactios = InteractionInfo::where('dream_id',$id)->orderBy('id','desc')->get();
         foreach ($interactios as $item) {
-            dd($item->comments);
-//            $item->with(['comments']);
+            $item->comments;
             foreach ($item->comments as $comment) {
                 $comment->pic = UserInfoModel::find($comment->user_id)->pic;
-                $comment->replay = $comment->replay;
+                $comment->replay;
                 foreach ($comment->replay as $k1 => $v1){
                     $v1->pic =  UserInfoModel::find($v1->user_id)->pic;
                 }
             }
         }
-        if ($type == 'interaction') return $this->api(compact('data'));
+        if ($type == 'interaction') return $this->api(compact('interactios'));
 //            梦想  图片  支持者前三    支持乘数参数    用户余额   梦想分数
 
 //            $money = $user->money;
-        $number = BaseSettingsModel::where('category','score')->select('key','value')->first()->moey;
-        $a = count($number) > 0 ? $number->key : '';
-        $c = count($number) > 0 ? $number->value : '';
+        $dream_info = DreamInfoModel::find($id);
+        $setting = BaseSettingsModel::where('category','score')->select('key','value')->first()->moey;
+        $a = count($setting) > 0 ? $setting->key : '';
+        $created_at = $dream_info ? $dream_info->created_at : 0;
+        $b =  intval((time()-strtotime($created_at))/3600) ;
+        $c = count($setting) > 0 ? $setting->value : '';
+        //Todo 支持乘数目公式
+        $number = -$a * $b + $c;
+        if ($number <= 1) $number = 1;
         $dream = DreamInfoModel::with(['imgs','user'])->find($id);
-//            $imgs = DreamImages::where('dream_id',$id)->orderBy('id','desc')->get();
-//        $info = SupportDreamModel::where('dream_id',$id)->get();
-        $top3 = [] ;
-        $score = 0 ;
-        foreach ($info as $item) {
-            $score += $item->score;
-            if (!array_key_exists($item->user_id,$top3)) {
-                $top3[$item->user_id] = $item->score;
-            }else{
-                $top3[$item->user_id] += $item->score;
-            }
-        }
-        arsort($top3);
-        foreach ($top3 as $k => $v){
-            $user = UserInfoModel::find($k);
-            if($user)
-            $top3[$k] = $user->pic;
-        }
-        return $this->api(compact('dream','top3user','a','c','score','topuser'));
+        return $this->api(compact('dream','top3user','number'));
     }
 
     /**
@@ -244,7 +205,7 @@ class DreamController extends Controller
             ],
             [
                 'coin.required'  => '梦想币不能为空',
-                'id.required'  => '支持梦想不能为空',
+                'id.required'  => '支持梦想id不能为空',
             ]
         );
         if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
@@ -256,21 +217,23 @@ class DreamController extends Controller
 
         $setting = BaseSettingsModel::where('category','score')->select('key','value')->first();
         $a = count($setting) > 0 ? $setting->key : '';
+        $b =  intval((time()-strtotime($dream_info->created_at))/3600) ;
         $c = count($setting) > 0 ? $setting->value : '';
         //Todo 支持乘数目公式
-        $number = 2;
+        $number = -$a * $b + $c;
+        if ($number <= 1) $number = 1;
 
-        if ($user->money < $coin) {
+        if ($user->coin < $coin) {
             return $this->error(ErrorCode::COIN_NOT_ENOUGH);
         }else{
-            $user->money  =  $user->money - $coin;
+            $user->coin  -= $coin;
             $user->save();
-            $dream_info->get_money += $coin;
+            $dream_info->get_coin += $coin;
             $dream_info->save();
             $data = [
                 'user_id'=>$user->id,
                 'dream_id'=>$dream_id,
-                'dream_user_id'=>$user_id,
+                'to_user_id'=>$user_id,
                 'coin'=>$coin,
                 'score'=>$coin*$number,
             ];
@@ -334,7 +297,7 @@ class DreamController extends Controller
                 'id'  => 'required',
             ],
             [
-                'id.required'  => '支持梦想不能为空',
+                'id.required'  => '收藏梦想id不能为空',
             ]
         );
         if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
@@ -345,78 +308,15 @@ class DreamController extends Controller
             'dream_id' =>$request->id,
             'dream_user_id' =>DreamInfoModel::find($request->id)->user_id,
         ];
-        $info = UserCareDream::where('user_id',$user->id)->
+        $user_care_dream = UserCareDream::where('user_id',$user->id)->
             where('dream_id',$request->id)->first();
-        if (count($info) == 0) {
+        if (!$user_care_dream) {
            UserCareDream::create($data);
         }
         return $this->api('');
 
     }
 
-//    发布关于梦想的动态
-    /**
-     * @api {post} /api/dream/add_info 新增动态
-     * @apiDescription 新增动态
-     * @apiGroup Dream
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiParam {int} id 梦想ID
-     * @apiParam {string} title 梦想标题
-     * @apiParam {array} pics[] 图片数组
-     * @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
-     * {
-     *     "state": false,
-     *     "code": 1000,
-     *     "message": "传入参数不正确",
-     *     "data": null or []
-     * }
-     *
-     */
-    public function addInfo(Request $request)
-    {
-        $validator = \Validator::make($request->all(),
-            [
-                'id'  => 'required',
-                'title'  => 'required',
-            ],
-            [
-                'dream_id.required'  => '梦想ID不能为空',
-                'title.required'  => '动态标题不能为空',
-            ]
-        );
-
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-        $pics = $request->pics;
-        if (empty($pics) || !is_array($pics)) {
-            return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
-        }
-        $data = [];
-        foreach ($pics as $k => $pic) {
-            $data['pic'.($k+1)] = $pic;
-        }
-        $dream_id = $request->id;
-        $title = $request->title;
-        $data['dream_id'] = $dream_id;
-        $data['title'] = $title;
-        $ok = InteractionInfo::create($data);
-        if ($ok) {
-//            收藏梦想最新动态加一
-            UserCareDream::where('dream_id',$dream_id)->increment('interaction_number',1);
-            return $this->api('');
-        }else{
-            return $this->error(ErrorCode::SAVE_USER_FAILED);
-        }
-    }
     /**
      * @api {get}  /api/dream/search 梦想搜索
      * @apiDescription 梦想搜索)
@@ -476,4 +376,104 @@ class DreamController extends Controller
         }
 
     }
+
+    /**
+     * @api {post} /api/dream/store 发布梦想
+     * @apiDescription 发布梦想
+     * @apiParam {string}  pics          梦想图片 数组
+     * @apiParam {string}  video         梦想视频
+     * @apiParam {string}  name          梦想标题
+     * @apiParam {string}  about         梦想介绍
+     * @apiParam {int}  coin             梦想币
+     * @apiParam {int}  time             实现时间默认21*3600
+     * @apiGroup Dream
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiSuccessExample {json} Success-Response:
+     * {
+     *    "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *    "data": ""
+     *}
+     * HTTP/1.1 200 OK
+     * @apiErrorExample {json} Error-Response:
+     * {
+     *    "status": false,
+     *    "status_code": 1203,
+     *    "message": "附件不存在",
+     *    "data": null
+     * }
+     * HTTP/1.1 400 Bad Request
+     */
+    public function store(Request $request)
+    {
+        $user = $this->getUser();
+        $validator = \Validator::make($request->all(),
+            [
+                'name'  => 'required',
+                'about'  => 'required',
+                'coin'  => 'required|integer',
+                'time'  => 'required|integer',
+            ],
+            [
+                'name.required'  => '梦想标题必填',
+                'about.required'  => '梦想介绍必填',
+                'coin.required'  => '梦想币必填',
+                'coin.integer'  => '梦想币必须是正整数',
+                'time.required'  => '实现时间必填',
+                'time.integer'  => '实现时间必须是正整数',
+            ]
+        );
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+        \Log::debug($user);
+        $data2 = $user->myCareNum;
+        $care_num = count($data2);
+        $setting = BaseSettingsModel::where('category','paihang')->first();
+        $a = $setting?$setting->key:1;
+        $b = $setting?$setting->value:1;
+        $t = 21*3600 / 60;
+
+        $data = $request->except('_token','pics');
+        $data['user_id'] = $user->id;
+        \Log::debug(' care_num:'.$care_num.' a:'.$a.' b:'.$b.' t:'.$t);
+        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)->paginate(20);
+                     foreach ($info as $item) {
+                         $item->dream_num += 1;
+                         $item->updated_at = date('Y-m-d H:i:s');
+                         $item->save();
+                     }*/
+            $pics = $request->pics;
+            $video = $request->video;
+            if (!is_array($pics) && empty($pics) && empty($video)) {
+                DreamInfoModel::destroy($dream_id);
+                return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
+            }
+            $data = [];
+            if (is_array($pics)) {
+                foreach ($pics as $v){
+                    $data[] = [
+                        'dream_id'=>$dream_id,
+                        'pic' => $v,
+                        'created_at' =>date('Y-m-d H:i:s'),
+                        'updated_at' =>date('Y-m-d H:i:s'),
+                    ];
+                }
+                DreamImages::insert($data);
+            }
+            return $this->api('');
+        }
+    }
+
 }

+ 10 - 11
server/app/Http/Controllers/Api/V1/HomeController.php

xqd xqd xqd xqd xqd
@@ -16,8 +16,8 @@ use App\Services\Base\ErrorCode;
 class HomeController extends Controller
 {
     /**
-     * @api {get} /api/user/index/ 用户信息(index)
-     * @apiDescription 用户信息(index)
+     * @api {get} /api/user/show/ 用户信息
+     * @apiDescription 用户信息
      * @apiGroup Home
      * @apiPermission Passport
      * @apiVersion 0.1.0
@@ -32,7 +32,7 @@ class HomeController extends Controller
      *      "user": {},             用户信息
      *      "near_dream": {},       当前梦想
      *      "sup_dreams": [],       支持的梦想
-     *      "all_imgs": [],         封面图片
+     *      "imgs": [],         封面图片
      *      "dreams": []            曾经的梦想
      *      "score": 2000           支持分数
      *  }
@@ -40,13 +40,13 @@ class HomeController extends Controller
      * @apiErrorExample {json} Error-Response:
      *HTTP/1.1 400 Bad Request
      *{
-     *"status": false,
-     *"status_code": 1105,
-     * "message": "用户不存在",
-     *"data": null
+     *  "status": false,
+     *  " status_code": 1105,
+     *  "message": "用户不存在",
+     *  "data": null
      *  }
      */
-    public function index(Request $request)
+    public function show(Request $request)
     {
         $user_id = $request->user_id;
 //        获得的支持分数
@@ -66,7 +66,7 @@ class HomeController extends Controller
 //        当前梦想
         $near_dream =DreamInfoModel::where('user_id',$user->id)->orderBy('id','desc')->first();
 //         封面图片
-        $all_imgs =$user->allImgs;
+        $imgs =$user->allImgs;
 //        曾经的梦想
         $dreams = $user->UserDream;
 
@@ -86,8 +86,7 @@ class HomeController extends Controller
             $sup_dream->pics = $sup_dream->imgs;
         }
 
-        return $this->api(compact('user','near_dream','sup_dreams','all_imgs','dreams','score'));
+        return $this->api(compact('user','near_dream','sup_dreams','imgs','dreams','score'));
 
     }
-
 }

+ 161 - 307
server/app/Http/Controllers/Api/V1/IndexController.php

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -15,7 +15,7 @@ class IndexController extends Controller
 {
 
     /**
-     * @api {get} /api/index/index 首页
+     * @api {get} /api/index/home 首页
      * @apiDescription 首页
      * @apiGroup Index
      * @apiParam {string}  type   (热门)hot/(潮流)trend/(最新)news
@@ -25,141 +25,59 @@ class IndexController extends Controller
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      *{
-     *   "status": true,
+     *  "status": true,
      *  "status_code": 0,
-     *   "message": "",
-     *   "data": {
-     *       "banner": [            轮播图
-     *          {
-     *              "value": "http://w17.9026.com/img/banner/banner_2.png",
-     *          },
+     *  "message": "",
+     *  "data": {
+     *      "banners": [                                      轮播图
      *          {
-     *               "value": "http://w17.9026.com/img/banner/banner_3.png",
-     *           },
+     *              "id": 34,
+     *               "key": "4",
+     *              "value": "http://w17.9026.com/img/banner/banner_4.png",
+     *              "sort": 0,
+     *              "category": "banner",
+     *              "pid": 0,
+     *              "status": 1,
+     *              "created_at": null,
+     *              "updated_at": null,
+     *             "deleted_at": null
+     *          }
      *      ],
-     *   "users": {
-     *      "1": [               1用户ID
-     *          [
-     *              {                                   用户梦想互动
-     *                  "id": 8,
-     *                  "dream_id": 1,
-     *                  "title": "2",
-     *                  "pic1": "www.buniang.com",
-     *                 "pic2": "",
-     *                  "pic3": "",
-     *                 "pic4": "",
-     *                  "pic5": "",
-     *                 "pic6": "",
-     *                  "pic7": "",
-     *                   "pic8": "",
-     *                  "pic9": "",
-     *                  "status": 1,
-     *                  "created_at": "2017-06-23 08:13:39",
-     *                  "updated_at": "2017-06-23 08:13:39",
-     *                  "deleted_at": null,
-     *                  "user_id": 1
-     *              },
+     *      "users": [],                                     动态用户
+     *      "dreams": {                                      梦想列表
+     *          "current_page": 1,
+     *          "data": [
      *              {
-     *                  "id": 9,
-     *                  "dream_id": 1,
-     *                  "title": "2haha",
-     *                  "pic1": "www.buniang.com",
-     *                  "pic2": "",
-     *                  "pic3": "",
-     *                  "pic4": "",
-     *                  "pic5": "",
-     *                  "pic6": "",
-     *                  "pic7": "",
-     *                  "pic8": "",
-     *                  "pic9": "",
-     *                  "status": 1,
-     *                  "created_at": "2017-06-23 08:15:01",
-     *                  "updated_at": "2017-06-23 08:15:01",
-     *                 "deleted_at": null,
-     *                  "user_id": 1
+     *                  "id": 5,
+     *                  "user_id": 1,
+     *                 "name": "梦想标题1",
+     *                  "about": "梦想介绍",
+     *                  "coin": 2500,
+     *                  "time": 21,                         实现时间
+     *                  "get_coin": 0,
+     *                  "status": 0,
+     *                  "video": null,
+     *                  "score": 100079365,
+     *                  "sign": "",
+     *                  "created_at": "2017-06-25 12:45:22",
+     *                  "updated_at": "2017-06-25 12:45:22",
+     *                  "care_num": 0,                       关注人数
+     *                 "img": {
+     *                  "title": "",
+     *                        "pic": "https://timgsa.baidu.com/timg?ica852e6e9c6ec46b7b14f12f.jpg"       梦想封面图片
+     *                   }
      *              },
      *          ],
-     *          "http://www.wsfjq.com/photos/bd119684755.jpg"            用户头像
-     *           3                                      新消息条数
-     *      ],
-     *}
-     *      "dreams": {                             梦想列表
-     *      "current_page": 1,
-     *      "data": [
-     *           {
-     *              "id": 1,
-     *               "user_id": 1,
-     *              "dream": "梦想标题",
-     *               "about": "梦想烧",
-     *               "video": "",
-     *               "money": 10000,
-     *              "time": 720000,
-     *              "get_money": 0,
-     *              "status": 0,
-     *              "updated_at": "2017-06-22 09:42:41",
-     *              "dream_user": {                         梦想所有者
-     *               "nickname": "ha",
-     *              "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",
-     *               "money": 123568,
-     *               "sex": 1,
-     *               "signture": "signture",
-     *              "city": "",
-     *              "birthday": "2017-06-21",
-     *               "status": 1,
-     *           },
-     *          "care_num": 1,                        关注人数
-     *          "dream_imgs_first": {                 梦想封面图片
-     *              "title": "",
-     *               "pic": "http://w17.9026.com/img/banner/banner_3.png"
-     *          },
-     *          "dream_detailed": {                    点击进入梦想详情
-     *              "dream_imgs": [
-     *                  {
-     *                      "title": "",
-     *                      "pic": "http://w17.9026.com/img/banner/banner_3.png"
-     *                  },
-     *                  {
-     *                      "title": "",
-     *                     "pic": "http://w17.9026.com/img/banner/banner_3.png"
-     *                  }
-     *              ],
-     *              "comments": [
-     *                   {
-     *                      "user_id": 2,
-     *                      "level": 0,
-     *                      "content": "EST评论",
-     *                      "updated_at": null,
-     *                      "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",     评论者头像
-     *                     "replay": [
-     *                         {
-     *                              "user_id": 2,
-     *                              "level": 0,
-     *                              "content": "拉了",
-     *                              "updated_at": null,
-     *                              "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"         回复者头像
-     *                          },
-     *                          {
-     *                              "user_id": 3,
-     *                              "level": 0,
-     *                              "content": "userid3回复了你的消息",
-     *                              "updated_at": null,
-     *                              "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
-     *                          }
-     *                      ]
-     *                  },
-     *         }
-     *      ]
-     *      },
-     *      "from": 1,
-     *      "last_page": 1,
-     *      "next_page_url": null,
-     *      "path": "http://www.miao.com/api/index/index",
-     *      "per_page": 20,
-     *       "prev_page_url": null,
-     *      "to": 8,
-     *      "total": 8
-     *     }
-     *   }
+     *          "from": 1,
+     *          "last_page": 1,
+     *          "next_page_url": null,
+     *          "path": "http://www.miao.com/api/index/home",
+     *          "per_page": 20,
+     *          "prev_page_url": null,
+     *         "to": 5,
+     *          "total": 5
+     *      }
+     *  }
      *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
@@ -170,44 +88,21 @@ class IndexController extends Controller
      *     "data": null or []
      * }
      */
-    public function index(Request $request)
+    public function home(Request $request)
     {
-        $user = $this->getUser();
-        //        关注的梦想
-        $users =  $user->UserCareDream;
-//        $arr = UserInfoModel::where('id',$user->id)->whereHas('UserCareDream', function ($query) {
-//            $query->where('interaction_number', '>', 0);
-//        })->get();
-//        dd($arr->toArray());
-//        $users = [] ;
-//        $arr1 = [];
-//        foreach ($arr as $k => $v){
-//            if ($v->pivot->interaction_number > 0) {
-//                if (!array_key_exists($v->pivot->dream_user_id,$arr1)) {
-//                    $arr1[$v->pivot->dream_user_id] = $v->pivot->interaction_number;
-//                }else{
-//                    $arr1[$v->pivot->dream_user_id] += $v->pivot->interaction_number;
-//                }
-//            }
-//        }
-//        dd($arr1);
-//        foreach ($arr1 as $k => $v){
-//            $a = UserInfoModel::find($k);
-//            $users[$k] =[$a->allInteraction,$a->pic,$v] ;
-//        }
+        $users = [];
         $type = $request->type;
         if ($type == 'trend') {
-            $dreams = DreamInfoModel::orderBy('score','desc')->offset(20)->limit(100)->paginate(20);
+            $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->offset(20)->limit(100)->paginate(20);
             $this->dreams($dreams);
             return $this->api(compact('users','dreams'));
         } elseif ($type == 'news') {
-            $dreams = DreamInfoModel::orderBy('score','desc')->offset(100)->limit(500)->paginate(20);
+            $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->offset(100)->limit(500)->paginate(20);
             $this->dreams($dreams);
             return $this->api(compact('users','dreams'));
         } else{
             $banners = $this->getBanner();
-    //        获取其他用户信息 及梦想
-            $dreams = DreamInfoModel::orderBy('score','desc')->limit(20)->paginate(20);
+            $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->limit(20)->paginate(20);
             $this->dreams($dreams);
             return $this->api(compact('banners','users','dreams'));
         }
@@ -223,38 +118,59 @@ class IndexController extends Controller
      * @apiParam {string}  keyword   关键字可选  (ha)
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     *     get
+     *           get
      *{
-     *    "status": true,
+     *  "status": true,
      *  "status_code": 0,
-     *  "message": "",
+     *   "message": "",
      *  "data": {
-     *      "arr": {    // 热门搜索
-     *       ...
+     *       "hot_searches": {
+     *          "name": 1,
+     *          "梦想": 1,
+     *          "ha": 1
      *      },
-     *      "data1": [
+     *      "history_searches": [
      *          {
-     *              "search": "ha",  //  历史搜索
-     *          }
+     *              "id": 3,
+     *              "user_id": 1,
+     *              "search": "ha",
+     *               "times": 1,
+     *              "created_at": "2017-06-25 16:21:47",
+     *               "updated_at": "2017-06-25 16:21:47"
+     *          },
      *      ]
      *  }
      *}
-     * post
-     * {
-     *   "status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": {
-     *      "data1": [
-     *          ...  //用户
-     *       ],
-     *       "data2": [
-     *            ...   //梦想
-     *       ],
-     *      "data3": [
-     *            ...   //标签
-     *       ]
-     *    }
+     *               post
+     *{
+     *  "status": true,
+     *  "status_code": 0,
+     *  "message": "",
+     *  "data": {
+     *       "user_infos": [
+     *          {
+     *              "id": 1,
+     *              "phone": "13880642880",
+     *              "nickname": "name1",
+     *              "avatar": "https://timgsa.baidu.com/ti.thumb.224_0.jpeg",
+     *              },
+     *      ],
+     *      "dream_infos": [
+     *           {
+     *              "id": 5,
+     *              "user_id": 1,
+     *              "name": "梦想标题1",
+     *              "about": "梦想介绍",
+     *          },
+     *      ],
+     *      "signs": [
+     *          {
+     *              "id": 1013,
+     *              "key": "",
+     *              "value": "ha",                 标签名
+     *          },
+     *      ]
+     *  }
      *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
@@ -263,37 +179,37 @@ class IndexController extends Controller
     {
         $user = $this->getUser();
         $keyword ='%'.$request->keyword.'%';
-        $data1 = UserInfoModel::where('nickname','like',$keyword)->get();
-        $data2 = DreamInfoModel::where('dream','like',$keyword)->
+        $user_infos = UserInfoModel::where('nickname','like',$keyword)->get();
+        $dream_infos = DreamInfoModel::where('name','like',$keyword)->
             orWhere('sign','like',$keyword)->get();
-        $data3  = BaseSettingsModel::where('category','sign')->where('value','like',$keyword)->get();
+        $signs  = BaseSettingsModel::where('category','sign')->where('value','like',$keyword)->get();
         if (empty($request->keyword)) {
 //            历史搜索
-                $data1  = $user->search()->orderBy('id','desc')->limit(10)->get();
+                $history_searches  = $user->search()->orderBy('id','desc')->limit(10)->get();
 //            热门搜索
                 $data2 = SearchInfoModel::get();
-                $arr = [];
+                 $hot_searches = [];
                 foreach ($data2 as $k => $v) {
-                    if (count($arr) == 8) {
+                    if (count($hot_searches) == 8) {
                         break;
                     }
-                    if (!array_key_exists($v->search,$arr)) {
-                        $arr[$v->search] = $v->times;
+                    if (!array_key_exists($v->search,$hot_searches)) {
+                        $hot_searches[$v->search] = $v->times;
                     }else{
-                        $arr[$v->search] += $v->times;
+                        $hot_searches[$v->search] += $v->times;
                     }
                 }
-                arsort($arr);
-                return $this->api(compact('arr','data1'));
+                arsort($hot_searches);
+                return $this->api(compact('hot_searches','history_searches'));
         }
 //        写入搜索记录
         $this->insertSearchTable($user->id,$request->keyword);
-        return $this->api(compact('data1','data2','data3'));
+        return $this->api(compact('user_infos','dream_infos','signs'));
     }
 
     /**
-     * @api {get}  /api/index/user_search 用户搜索(search)
-     * @apiDescription 用户搜索(search)
+     * @api {get}  /api/index/user_search 用户搜索
+     * @apiDescription 用户搜索
      * @apiGroup Index
      * @apiPermission none
      * @apiVersion 0.1.0
@@ -302,15 +218,15 @@ class IndexController extends Controller
      * HTTP/1.1 200 OK
      *{
      *    "status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *  "data": {
-     *       "data1": [
-     *          "nickname": "ha",  昵称
-     *          "pic": "",    头像
-     *             ...
-     *       ]
-     *   }
+     *    "status_code": 0,
+     *    "message": "",
+     *    "data":[
+     *      {
+     *         "nickname": "ha",  昵称
+     *         "pic": "",    头像
+     *          ...
+     *      },
+     *   ]
      *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
@@ -322,13 +238,11 @@ class IndexController extends Controller
             return $this->api('');
         }
         $keyword ='%'.$request->keyword.'%';
-        $data1 = UserInfoModel::where('nickname','like',$keyword)->get();
+        $users = UserInfoModel::where('nickname','like',$keyword)->get();
         $this->insertSearchTable($user->id,$request->keyword);
-        return $this->api(compact('data1'));
+        return $this->api($users);
     }
 
-
-
     //获取轮播图
     public function getBanner()
     {
@@ -341,110 +255,50 @@ class IndexController extends Controller
     public function dreams($dreams)
     {
         foreach ($dreams as $k => $dream) {
-            $dream->dream_user =  $dream->user;
-//            计算被关注总人数
-            $user_id =  $dream->user_id;
             $data = UserCareDream::where('dream_id',$dream->id)->get();
             $dream->care_num = count($data);
-            $dream->dream_imgs_first = $dream->dreamImgsFirst?$dream->dreamImgsFirst->pic:'';
-//            梦想详情  detailed  图片 ,评论 ,回复
-            $arr = [] ;
-            $arr['dream_imgs'] = $dream->imgs;
-            $dream->dream_detailed = $arr;
+            $dream->img = $dream->img?$dream->img->pic:'';
         }
     }
 //    查看关注用户的最新动态
-    /**
-     * @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": {
-     *      "all_interaction": [                          互动
-     *          {
-     *              "id": 7,
-     *              "dream_id": 2,
-     *              "title": "梦想动态有力来了",
-     *              "pic1": "http\"//www.baidu.com",
-     *              "pic2": "",
-     *               "pic3": "",
-     *              "pic4": "",
-     *              "pic5": "",
-     *              "pic6": "",
-     *              "pic7": "",
-     *              "pic8": "",
-     *              "pic9": "",
-     *              "status": 1,
-     *              "created_at": "2017-06-22 21:09:18",
-     *              "updated_at": "2017-06-22 21:09:18",
-     *              "deleted_at": null,
-     *              "user_id": 2,
-     *              "time": 720000,                           倒计时
-     *              "comments": [                            评论
-     *                  {
-     *                      "interaction_id": 7,
-     *                      "user_id": 1,
-     *                      "level": 0,
-     *                      "content": "不错的梦想",
-     *                      "updated_at": null,
-     *                      "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",
-     *                      "replay": [                       回复
-     *                          {
-     *                              "user_id": 1,
-     *                              "level": 0,
-     *                              "content": "我也觉得不错",
-     *                              "updated_at": null,
-     *                              "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
-     *                          },
-     *                          {
-     *                              "user_id": 6,
-     *                              "level": 0,
-     *                              "content": "祝你梦想成真",
-     *                              "updated_at": null,
-     *                              "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
-     *                          }
-     *                      ]
-     *                  }
-     *               ]
-     *          },
-     *      ]
-     *  }
-     *}
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     */
-    public function newsInfo(Request $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);
+//        UserCareDream::where('user_id',$user->id)->where('dream_user_id',$other_id)->update(['interaction_number'=>0]);
+//        $data = UserInfoModel::where('id',$other_id)->with(['allInteraction'=>function ($query){
+//            $query->orderBy('id','desc');
+//        }])->first();
+////        $data = UserInfoModel::find($other_id)->allInteraction;
+////        dd($data) ;
+////        dd($data->allInteraction);
+//        foreach ($data->allInteraction as $item) {
+//            $item->time = DreamInfoModel::find($item->dream_id)->time;
+//            $item->comments = $item->comments;
+//            foreach ($item->comments as $k => $v) {
+//                $v->pic = UserInfoModel::find($v->user_id)->pic;
+//                $v->replay = $v->replay;
+//                foreach ($v->replay as $k1 => $v1) {
+//                    $v1->pic = UserInfoModel::find($v1->user_id)->pic;
+//                }
+//            }
+//        }
+//        return $this->api($data);
+//    }
+    public function insertSearchTable($id,$keyword)
     {
-//        查看后user_care_user dream_info 更新为零 首页不再显示
-        $user = $this->getUser();
-        $other_id = $request->id;
-        if (empty($other_id))  return $this->error(ErrorCode::MEMBER_NOT_EXIST);
-        UserCareDream::where('user_id',$user->id)->where('dream_user_id',$other_id)->update(['interaction_number'=>0]);
-        $data = UserInfoModel::where('id',$other_id)->with(['allInteraction'=>function ($query){
-            $query->orderBy('id','desc');
-        }])->first();
-//        $data = UserInfoModel::find($other_id)->allInteraction;
-//        dd($data) ;
-//        dd($data->allInteraction);
-        foreach ($data->allInteraction as $item) {
-            $item->time = DreamInfoModel::find($item->dream_id)->time;
-            $item->comments = $item->comments;
-            foreach ($item->comments as $k => $v) {
-                $v->pic = UserInfoModel::find($v->user_id)->pic;
-                $v->replay = $v->replay;
-                foreach ($v->replay as $k1 => $v1) {
-                    $v1->pic = UserInfoModel::find($v1->user_id)->pic;
-                }
-            }
+        $info = SearchInfoModel::where('user_id',$id)->
+        where('search',trim($keyword))->first();
+        if (count($info) == 0) {
+            SearchInfoModel::create(['user_id'=>$id,'search'=>trim($keyword),'times'=>1]);
+        }else{
+            $info->times += 1;
+            $info->save();
         }
-        return $this->api($data);
+
     }
+
 }

+ 188 - 0
server/app/Http/Controllers/Api/V1/InteractionController.php

xqd
@@ -0,0 +1,188 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use App\Models\CommentInfoModel;
+use Illuminate\Http\Request;
+use App\Services\Base\ErrorCode;
+class InteractionController extends Controller
+{
+    //    发布关于梦想的动态
+    /**
+     * @api {post} /api/interaction/store 新增动态
+     * @apiDescription 新增动态
+     * @apiGroup Interaction
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} id                 梦想ID
+     * @apiParam {string} title           梦想标题
+     * @apiParam {array} pics[]           图片数组
+     * @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
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     *
+     */
+    public function store(Request $request)
+    {
+        $validator = \Validator::make($request->all(),
+            [
+                'id'  => 'required',
+                'title'  => 'required',
+            ],
+            [
+                'id.required'  => '梦想ID不能为空',
+                'title.required'  => '动态标题不能为空',
+            ]
+        );
+
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+        $pics = $request->pics;
+        if (empty($pics) || !is_array($pics)) {
+            return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
+        }
+        $data = [];
+        foreach ($pics as $k => $pic) {
+            $data['pic'.($k+1)] = $pic;
+        }
+        $dream_id = $request->id;
+        $title = $request->title;
+        $data['dream_id'] = $dream_id;
+        $data['title'] = $title;
+        $ok = InteractionInfo::create($data);
+        if ($ok) {
+//            收藏梦想最新动态加一
+            UserCareDream::where('dream_id',$dream_id)->increment('interaction_number',1);
+            return $this->api('');
+        }else{
+            return $this->error(ErrorCode::SAVE_USER_FAILED);
+        }
+    }
+
+    //    评论互动
+
+    /**
+     * @api {post} /api/interaction/comments 评论动态
+     * @apiDescription 评论动态
+     * @apiGroup Interaction
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} id                   动态ID不存在
+     * @apiParam {string} content           内容不能为空
+     * @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
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     *
+     */
+    public function comments(Request $request)
+    {
+        $validator = \Validator::make($request->all(),
+            [
+                'id'  => 'required',
+                'content'  => 'required',
+            ],
+            [
+                'id.required'  => '动态ID不存在',
+                'content.required'  => '内容不能为空',
+            ]
+        );
+
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+
+        $user = $this->getUser();
+        $user_id = $user->id;
+        $interaction_id = $request->id;
+        $content = $request->content;
+        $data = compact('user_id','interaction_id','content');
+        $ok = CommentInfoModel::create($data);
+        if ($ok) {
+            return $this->api('');
+        }else{
+            return $this->error(ErrorCode::OPERATION_FAILED);
+        }
+    }
+
+    //    回复评论
+
+    /**
+     * @api {post} /api/interaction/reply 我的回复
+     * @apiDescription 我的回复
+     * @apiGroup Interaction
+     * @apiParam {text}  content        回复内容
+     * @apiParam {int} comment_id       评论ID
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiSuccessExample {json} Success-Response:
+     * {
+     *  "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *   "data": ""
+     *}
+     * HTTP/1.1 200 OK
+     * @apiErrorExample {json} Error-Response:
+     * {
+     *   "status": false,
+     *   "status_code": 1000,
+     *   "message": "输入不正确",
+     *  "data": null
+     *}
+     * HTTP/1.1 400 Bad Request
+     */
+    public function reply(Request $request)
+    {
+        $validator = \Validator::make($request->all(),
+            [
+                'id'  => 'required',
+                'content'  => 'required',
+            ],
+            [
+                'id.required'  => '评论ID不存在',
+                'content.required'  => '内容不能为空',
+            ]
+        );
+
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+
+        $user = $this->getUser();
+        $data['user_id'] = $user->id;
+        $data['comment_id'] = $request->id;
+        $data['content'] = $request->content;
+
+        if (!$request->content)
+            return $this->error(ErrorCode::CONNET_NOT_EXIST);
+
+        $ok =  ReplyCommentsInfo::create($data);
+
+        if ($ok) {
+            return $this->api('');
+        }else{
+            return $this->error(ErrorCode::OPERATION_FAILED);
+        }
+    }
+}

+ 163 - 303
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -8,44 +8,53 @@ use App\Models\DreamImages;
 use App\Models\DreamInfoModel;
 use App\Models\ReplyCommentsInfo;
 use App\Models\SystemInfoModel;
-use App\Models\UserCareUser;
-use App\Models\UserDream;
+use App\Models\UserCareDream;
 use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
 use App\Services\Base\ErrorCode;
 class MyController extends Controller
 {
     /**
-     * @api {get} /api/my/show 个人首页(index)
-     * @apiDescription 个人首页(index)
+     * @api {get} /api/my/show 个人首页
+     * @apiDescription 个人首页
      * @apiGroup My
      * @apiPermission Passport
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 O*  "status": true,
-     *  "status_code": 0,
-     *  "message": "",
-     *  "data": {
-     *          "id": 1,
-     *          "tel": "13880642880",
-     *          "password": "",
-     *           "nickname": "",
-     *          "pic": "",
-     *          "sign": 0,
-     *          "money": 0,余额
-     *          "sex": 1,
-     *          "signture": "",个性签名
-     *          "tall": "",
-     *          "job": "",
-     *          "emotion": 1,
-     *          "address": "",
-     *          "detail_address": "",
-     *          "status": 1,
-     *          "remember_token": "",
-         *      "care_num": 4,关注
-         *      "fens_num": 3,粉丝
-         *      "collection_num": 2,收藏
-         *      "dream_num": 1,发帖
-     *  }
+     *{
+     *    "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *   "data": {
+     *       "id": 1,
+     *       "phone": "13880642880",
+     *       "nickname": "name1",
+     *       "avatar": "https://tims%2Fitem%225_kzrcM.thumb.224_0.jpeg",
+     *       "birthday": "2000-06-21",
+     *       "sign": 0,
+     *       "money": 0,
+     *       "coin": 1300,
+     *       "sex": 1,
+     *       "signture": "",
+     *       "height": 170,
+     *       "work": "",
+     *       "emotion": 1,
+     *       "address": "",
+     *       "city": "",
+     *       "detail_address": "",
+     *       "status": 1,
+     *       "wechat": "",
+     *        "weibo": "",
+     *       "remember_token": "",
+     *       "created_at": "2017-06-25 10:27:08",
+     *       "updated_at": "2017-06-25 15:20:11",
+     *       "deleted_at": null,
+     *       "care_dreams_number": 2,
+     *       "fans_number": 0,
+     *       "collection_number": 0,
+     *       "interaction_number": 0,
+     *   }
+     *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      *{
@@ -64,20 +73,20 @@ class MyController extends Controller
          * 我的关注人数,我的粉丝,收藏
          * 点赞?徽章?
          * */
-        $data1 = $user->myCareNum;
-        $user->care_num = count($data1);
-        $data2 = $user->myFans;
-        $user->fans_num = count($data2);
-        $data3 = $user->myCollection;
-        $user->collection_num = count($data3);
-        $data4 = $user->UserDream;
-        $user->dream_num = count($data4);
+        $care_num = $user->careDreams;
+        $user->care_dreams_number = count($care_num);
+        $fens = UserCareDream::where('dream_user_id',$user->id)->get();
+        $user->fans_number = count($fens);
+        $collection = $user->myCollection;
+        $user->collection_number = count($collection);
+        $interaction_infos = $user->allInteraction;
+        $user->interaction_number = count($interaction_infos);
         return $this->api($user);
     }
 
 
     /**
-     * @api {get} /api/my/edit_user_info 修改个人信息
+     * @api {get} /api/my/edit 修改个人信息
      * @apiDescription 修改个人信息
      * @apiGroup My
      * @apiPermission Passport
@@ -124,26 +133,26 @@ class MyController extends Controller
      *   "data": null
      *  }
      */
-    public function  editUserInfo (Request $request)
+    public function  edit()
     {
         $sex = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
-             where('dictionary_code','sex')->paginate(20);
+             where('dictionary_code','sex')->get();
         $emotion = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
-             where('dictionary_code','emotion')->paginate(20);
+             where('dictionary_code','emotion')->get();
 
         return $this->api(compact('emotion','sex'));
 
     }
 
     /**
-     * @api {post} /api/my/update_user_info 保存个人信息
+     * @api {post} /api/my/update 保存个人信息
      * @apiDescription   保存个人信息
      *      @apiParam {string} pic   头像
      *      @apiParam {int} sex   性别
      *      @apiParam {string} signture   个性签名
      *      @apiParam {int} emotion   情感状态
-     *      @apiParam {string} job   职业
-     *      @apiParam {int} tall   身高
+     *      @apiParam {string} work   职业
+     *      @apiParam {int} height   身高
      * @apiGroup My
      * @apiPermission Passport
      * @apiVersion 0.1.0
@@ -164,7 +173,7 @@ class MyController extends Controller
      *   "data": null
      * }
      */
-    public function updateUserInfo(Request $request)
+    public function update(Request $request)
     {
         $user = $this->getUser();
         $data = $request->except('_token');
@@ -177,9 +186,10 @@ class MyController extends Controller
     }
 
     /**
-     * @api {get} /api/my/recharge 充值(recharge)
+     * @api {post} /api/my/recharge 充值(recharge)
      * @apiDescription 充值(recharge)
      * @apiGroup My
+     *    @apiParam {int} coin       充值金额
      * @apiPermission Passport
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
@@ -191,20 +201,20 @@ class MyController extends Controller
     {
         $validator = \Validator::make($request->all(),
             [
-                'money'  => 'required|integer',
+                'coin'  => 'required|integer',
             ],
             [
-                'money.required'  => '请输入金额',
-                'money.integer'  => '请输入整数',
+                'coin.required'  => '请填写金额',
+                'coin.integer'  => '请输入整数',
 
             ]
         );
         if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
 
         $user = $this->getUser();
-        $user->coin += $request->money;
+        $user->coin += $request->coin;
         $user->save();
-        return $this->api(compact('user'));
+        return $this->api('');
     }
 
     /**
@@ -226,14 +236,6 @@ class MyController extends Controller
      *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
-     * {
-     *   "status": true,
-     *  "status_code": 0,
-     *   "message": "",
-     *   "data": {
-     *        "data": []
-     *   }
-    *}
      */
     public function systemInfo()
     {
@@ -242,124 +244,40 @@ class MyController extends Controller
         return $this->api(compact('data'));
     }
 
-    /**
-     * @api {get} /api/my/reply_my 回复我的(replyMy)
-     * @apiDescription 回复我的(replyMy)
-     * @apiGroup My
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * HTTP/1.1 200 OK
-     *
-     * {
-     *    "status": true,
-     *    "status_code": 0,
-     *    "message": "",
-     *    "data": {
-     *        "comments_infos": [
-     *            {
-     *                 "id": 1,
-     *                "dream_id": 2,
-     *                "user_id": 2,
-     *                "level": 2,
-     *                "content": "啊哈", 评论内容
-     *               "created_at": null, 评论时间
-     *                "updated_at": null,
-     *                "deleted_at": null,
-     *                "dream_name": "去旅游去旅游2", 梦想介绍
-     *               "dream_pic": "aaaaa", 梦想图片
-     *                "progress": 0,   进度
-     *               "reviewer": "22222",  评论者
-     *                "reviewer_pic": "22222pic", 评论者头像
-     *           }
-     *       ]
-     *  }
-     * }
-     * @apiErrorExample {json} Error-Response:
-     * HTTP/1.1 400 Bad Request
-     */
-    public function replyMy()
-    {
-
-        $user = $this->getUser();
-//        梦想
-        $dreams = $user->UserDream;
-
-        $data = $user->allInteraction;
-        foreach ($data as $item) {
-            $item->get_money = $item->dream->get_money;
-            $item->money = $item->dream->money;
-        }
-        dd($data) ;
-        if (count($dreams) == 0)
-            return $this->error(ErrorCode::DREAM_NOT_EXIST);
-        $comments_infos = [];
-        foreach ($dreams as $dream){
-            $comments_info = $dream->DreamInfo;
-            if (count($comments_info) > 0) {
-                foreach ($comments_info as $k => $value) {
-                    $value->dream_name = $dream->dream;
-                    $value->dream_about = $dream->about;
-                    $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
-                    $value->progress = $dream->money == 0 ? 0 :  floor($dream->get_money/$dream->money);
-                    $value->reviewer = $value->CommentUser->nickname;
-                    $value->reviewer_pic = $value->CommentUser->pic;
-                }
-                $comments_infos[] = $comments_info;
-            }
-        }
-
-        return $this->api(compact('comments_infos'));
-    }
-
-    /**
-     * @api {post} /api/my/my_reply 我的回复(myReply)
-     * @apiDescription 我的回复(recharge)
-     * @apiGroup My
-     * @apiParam {text}  content   回复内容
-     * @apiParam {int} comment_id   评论ID
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * {
-     *  "status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": ""
-    *}
-     * HTTP/1.1 200 OK
-     * @apiErrorExample {json} Error-Response:
-     * {
-     *   "status": false,
-     *   "status_code": 1000,
-     *   "message": "输入不正确",
-     *  "data": null
-    *}
-    *{
-     *    "status": false,
-     *   "status_code": 600,
-     *   "message": "保存用户数据失败",
-     *   "data": null
-    *}
-     * HTTP/1.1 400 Bad Request
-     */
-    public function myReply(Request $request)
-    {
-        $user = $this->getUser();
-        $data = $request->except('_token');
-        $data['user_id'] = $user->id;
-
-        if (!$request->content)
-            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS);
-
-       $ok =  ReplyCommentsInfo::create($data);
-
-        if ($ok) {
-            return $this->api('');
-        }else{
-            return $this->error(ErrorCode::SAVE_USER_FAILED);
-        }
-    }
+//    回复我的
+//    public function replyMy()
+//    {
+//
+//        $user = $this->getUser();
+////        梦想
+//        $dreams = $user->UserDream;
+//
+//        $data = $user->allInteraction;
+//        foreach ($data as $item) {
+//            $item->get_money = $item->dream->get_money;
+//            $item->money = $item->dream->money;
+//        }
+//        dd($data) ;
+//        if (count($dreams) == 0)
+//            return $this->error(ErrorCode::DREAM_NOT_EXIST);
+//        $comments_infos = [];
+//        foreach ($dreams as $dream){
+//            $comments_info = $dream->DreamInfo;
+//            if (count($comments_info) > 0) {
+//                foreach ($comments_info as $k => $value) {
+//                    $value->dream_name = $dream->dream;
+//                    $value->dream_about = $dream->about;
+//                    $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
+//                    $value->progress = $dream->money == 0 ? 0 :  floor($dream->get_money/$dream->money);
+//                    $value->reviewer = $value->CommentUser->nickname;
+//                    $value->reviewer_pic = $value->CommentUser->pic;
+//                }
+//                $comments_infos[] = $comments_info;
+//            }
+//        }
+//
+//        return $this->api(compact('comments_infos'));
+//    }
 
     /**
      * @api {get} /api/my/dream 我的梦想(dream)
@@ -368,38 +286,42 @@ class MyController extends Controller
      * @apiPermission Passport
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
-     * {
-     *   "status": true,
-     *    "status_code": 0,
-     *     "message": "",
-     *     "data": {
-     *          "dreams": [
-     *        {
-     *           "id": 2,
-     *            "dream": "去旅游去旅游2",
-     *           "about": "欧冠胡234",
-     *            "dream_pic": "aaaaa",      封面图片
-     *            "progress": 0,  进度
-     *        ]
-     *     }
-     * }
      * HTTP/1.1 200 OK
+     *{
+     *   "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *   "data": [
+     *       {
+     *           "id": 5,
+     *           "user_id": 1,
+     *           "name": "梦想标题1",
+     *           "about": "梦想介绍",
+     *           "coin": 2500,
+     *           "time": 21,
+     *            "get_coin": 0,
+     *           "status": 0,
+     *           "video": null,
+     *           "sign": "",
+     *           "created_at": "2017-06-25 12:45:22",
+     *            "updated_at": "2017-06-25 12:45:22",
+     *           "pic": "https://timgsa.baidu.com/timg?image7b14f12f.jpg",
+     *       },
+     *   ]
+     *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      */
     public function dream()
     {
         $user = $this->getUser();
-//        梦想
-        $dreams = $user->UserDream;
+        $dreams = $user->dreams;
 
         if (count($dreams) == 0)
             return $this->error(ErrorCode::DREAM_NOT_EXIST);
 
         foreach ($dreams as $dream){
-            $dream->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
-
-            $dream->progress = $dream->money == 0 ? 0 :  floor($dream->get_money/$dream->money);
+            $dream->pic = count($dream->img) > 0 ? $dream->img->pic : '';
         }
 
         return $this->api($dreams);
@@ -413,14 +335,53 @@ class MyController extends Controller
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
+     *{
+     *   "status": true,
+     *   "status_code": 0,
+     *   "message": "",
+     *   "data": {
+     *       "data": [
+     *           {                                   梦想详情
+     *               "id": 12,
+     *               "user_id": 2,
+     *              "name": "用户2梦想标题166",
+     *               "about": "用户2梦想介绍666",
+     *               "coin": 2500,
+     *               "time": 21,
+     *               "get_coin": 0,
+     *               "status": 0,
+     *               "video": null,
+     *               "sign": "",
+     *           },
+     *           "img": {
+     *               "title": "",
+     *               "pic": "https://f12f.jpg"      梦想封面图片
+     *            }
+     *       ],
+     *       "users": {
+     *           "2": "https://xxx.jpeg"           ID号和头像
+     *       }
+     *   }
+     *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      */
     public function collection()
     {
         $user = $this->getUser();
-        $data = $user->myCollection;
-        return $this->api(compact('data'));
+        $data = $user->collection;
+        $users = [];
+        foreach ($data as $item) {
+            if ($item->pivot->interaction_number > 0) {
+                $user_info = UserInfoModel::find($item->pivot->dream_user_id);
+                $avatar = $user_info ?  $user_info->avatar : '';
+                if (!array_key_exists($item->pivot->dream_user_id,$users)) {
+                    $users[$item->pivot->dream_user_id] = $avatar;
+                }
+            }
+           $item->img;
+        }
+        return $this->api(compact('data','users'));
     }
 
     /**
@@ -433,13 +394,11 @@ class MyController extends Controller
      * HTTP/1.1 200 OK
      *{
      *   "status": true,
-     **   "status_code": 0,
+     *   "status_code": 0,
      *   "message": "",
      *   "data": {
-     *      "data": {
-     *           "key": "2511789",               电话
-     *           "value": "关于喵喵介绍"          介绍
-     *       }
+     *       "key": "2511789",                    电话
+     *       "value": "关于喵喵介绍"              关于喵喵
      *   }
      *}
      * @apiErrorExample {json} Error-Response:
@@ -448,106 +407,7 @@ class MyController extends Controller
     public function setting()
     {
         $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
-        return $this->api(compact('data'));
-    }
-
-    /**
-     * @api {post} /api/my/store_dream 发布梦想
-     * @apiDescription 发布梦想
-       * @apiParam {string}  pics   梦想图片 数组
-       * @apiParam {string}  video   梦想视频
-       * @apiParam {string}  name   梦想标题
-       * @apiParam {string}  about   梦想介绍
-       * @apiParam {int}  coin   梦想币
-       * @apiParam {int}  time   实现时间默认21*3600
-     * @apiGroup My
-     * @apiPermission Passport
-     * @apiVersion 0.1.0
-     * @apiSuccessExample {json} Success-Response:
-     * {
-     *    "status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *    "data": ""
-     *}
-     * HTTP/1.1 200 OK
-     * @apiErrorExample {json} Error-Response:
-     * {
-     *    "status": false,
-     *    "status_code": 600,
-     *    "message": "保存用户数据失败",
-     *    "data": null
-     * }
-     * HTTP/1.1 400 Bad Request
-     */
-    public function storeDream(Request $request)
-    {
-        $user = $this->getUser();
-        $validator = \Validator::make($request->all(),
-            [
-                'name'  => 'required',
-                'about'  => 'required',
-                'coin'  => 'required|integer',
-                'time'  => 'required|integer',
-            ],
-            [
-                'name.required'  => '梦想标题必填',
-                'about.required'  => '梦想介绍必填',
-                'coin.required'  => '梦想币必填',
-                'coin.integer'  => '梦想币必须是正整数',
-                'time.required'  => '实现时间必填',
-                'time.integer'  => '实现时间必须是正整数',
-            ]
-        );
-        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
-        \Log::debug($user);
-        $data2 = $user->myCareNum;
-        $care_num = count($data2);
-        $setting = BaseSettingsModel::where('category','paihang')->first();
-        $a = $setting?$setting->key:1;
-        $b = $setting?$setting->value:1;
-        $t = 21*3600 / 60;
-
-        $data = $request->except('_token','pics');
-        $data['user_id'] = $user->id;
-        \Log::debug(' care_num:'.$care_num.' a:'.$a.' b:'.$b.' t:'.$t);
-        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)->paginate(20);
-            foreach ($info as $item) {
-                $item->dream_num += 1;
-                $item->updated_at = date('Y-m-d H:i:s');
-                $item->save();
-            }*/
-            $pics = $request->pics;
-            $video = $request->video;
-            if (empty($pics) && empty($video)) {
-                DreamInfoModel::destroy($dream_id);
-                return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
-            }
-            $data = [];
-                if (is_array($pics)) {
-                    foreach ($pics as $v){
-                        $data[] = [
-                            'dream_id'=>$dream_id,
-                            'pic' => $v,
-                            'created_at' =>date('Y-m-d H:i:s'),
-                            'updated_at' =>date('Y-m-d H:i:s'),
-                        ];
-                    }
-                    DreamImages::insert($data);
-                }
-                return $this->api('');
-            }
+        return $this->api($data);
     }
 
 }

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

xqd
@@ -8,7 +8,7 @@ class CommentInfoModel extends Model
 {
     protected $table = 'comments_info';
     protected $fillable = [
-        'dream_id',
+        'interaction_id',
         'user_id',
         'level',
         'content',

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

xqd
@@ -40,7 +40,7 @@ class DreamInfoModel extends BaseModel
                            'status'
                           ];
 
-    protected $hidden = ['score','deleted_at','mark'];
+    protected $hidden = ['deleted_at','mark'];
 
 
     public function user()

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

xqd xqd
@@ -72,7 +72,7 @@ class UserInfoModel extends Authenticatable
         return $this->hasMany('App\Models\SystemInfoModel','user_id','id');
     }
 //用户梦想
-    public function UserDream()
+    public function dreams()
     {
         return $this->hasMany('App\Models\DreamInfoModel','user_id','id');
     }
@@ -86,20 +86,20 @@ class UserInfoModel extends Authenticatable
     {
         return $this->belongsToMany('App\Models\DreamInfoModel','comments_info','user_id','dream_id')->withPivot('content', 'level','created_at');
     }
-//关注的用户
-    public function myCareNum()
+//收藏的梦想
+    public function careDreams()
     {
-        return $this->hasMany('App\Models\UserCareUser','user_id','id');
+        return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id');
     }
 //关注我的用户
-    public function myFans()
+    public function fens()
     {
         return $this->hasMany('App\Models\UserCareUser','other_user_id','id');
     }
 //    我的收藏
-    public function myCollection()
+    public function collection()
     {
-        return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id');
+        return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id')->withPivot('interaction_number','dream_user_id');
     }
 //    回复的梦想
     public function replyDream()

+ 4 - 4
server/app/Services/Base/ErrorCode.php

xqd xqd
@@ -45,13 +45,13 @@ final class ErrorCode {
     const SERVICE_STATUS_INVALID_CHANGE = 1406;
     const SERVICE_COST_OVERFLOW_BALANCE = 1407;
     const CREATE_SERVICE_OVER_MAX = 1408;
-    const SAVE_MODEL_FAILED = 700;
+    const OPERATION_FAILED = 700;
     const REMOVE_MODEL_FAILED = 701;
     const MODEL_NOT_EXIST = 702;
     const ATTACHMENT_UPLOAD_FAILED = 1200;
     const PROTO_PATH_NOT_EXIST = 100;
     const PROTO_TRY_TO_SET_VALUE_ON_NULL = 101;
-    const ACTIVITY_NOT_EXIST = 1700;
+    const CONNET_NOT_EXIST = 1700;
     const ORDER_GENERATE_FAILED = 1800;
     const CONSUME_LOG_NOT_EXIST = 1600;
     const SERVICE_CODE_FAILED= 1610;
@@ -101,13 +101,13 @@ final class ErrorCode {
         self::SERVICE_STATUS_INVALID_CHANGE => '服务状态转换无效',
         self::CANT_ADD_SERVICE_SAME_MERCHANT => '服务发出方与创建方一致',
         self::MERCHANT_SERVICE_EXPIRED => '服务已过期',
-        self::SAVE_MODEL_FAILED => '保存模型失败',
+        self::OPERATION_FAILED => '操作失败',
         self::REMOVE_MODEL_FAILED => '删除模型失败',
         self::MODEL_NOT_EXIST => '模型不存在',
         self::ATTACHMENT_UPLOAD_FAILED => '附件上传失败',
         self::PROTO_PATH_NOT_EXIST => '指定API路径不存在',
         self::PROTO_TRY_TO_SET_VALUE_ON_NULL => '企图操作NULL对象并赋值',
-        self::ACTIVITY_NOT_EXIST => '活动不存在',
+        self::CONNET_NOT_EXIST => '内容不能为空',
         self::ORDER_GENERATE_FAILED => '生成订单失败',
         self::CONSUME_LOG_NOT_EXIST => '消费记录不存在',
         self::LOGOUT_FAILED => '退出失败',

+ 1 - 1
server/database/migrations/2017_06_01_091444_create_user_info_table.php

xqd
@@ -22,7 +22,7 @@ class CreateUserInfoTable extends Migration
             $table->char('phone',11)->unique()->comment('电话');
             $table->string('password',100)->default('')->comment('密码');
             $table->string('nickname',100)->default('')->comment('昵称');
-            $table->string('avatar',100)->default('')->comment('用户头像');
+            $table->string('avatar')->default('')->comment('用户头像');
             $table->date('birthday')->default('2000-06-21');
             $table->integer('sign')->default(0)->comment('用户标签');
             $table->integer('money')->default(0)->comment('现金余额');

+ 1 - 1
server/database/migrations/2017_06_03_035722_create_user_care_dream_table.php

xqd
@@ -18,7 +18,7 @@ class CreateUserCareDreamTable extends Migration
             $table->integer('user_id')->comment('当前用户ID');
             $table->integer('dream_id')->comment('关注梦想ID');
             $table->integer('dream_user_id')->comment('梦想用户ID');
-            $table->integer('interaction_number')->comment('最新动态数量');
+            $table->integer('interaction_number')->default(0)->comment('最新动态数量');
             $table->timestamps();
         });
     }

+ 29 - 52
server/routes/api.php

xqd xqd xqd xqd xqd xqd
@@ -84,9 +84,9 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
 
 
 //首页
-    $api->get('index/index', [
-        'as' => 'index.index',
-        'uses' => 'IndexController@index',
+    $api->get('index/home', [
+        'as' => 'index.home',
+        'uses' => 'IndexController@home',
     ]);
     $api->get('index/search', [
         'as' => 'index.search',
@@ -96,14 +96,6 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         '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/show', [
@@ -114,16 +106,16 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.persona',
         'uses' => 'MyController@persona',
     ]);
-    $api->get('my/edit_user_info', [
-        'as' => 'my.edit_user_info',
-        'uses' => 'MyController@editUserInfo',
+    $api->get('my/edit', [
+        'as' => 'my.edit',
+        'uses' => 'MyController@edit',
     ]);
-    $api->post('my/update_user_info', [
-        'as' => 'my.update_user_info',
-        'uses' => 'MyController@updateUserInfo',
+    $api->post('my/update', [
+        'as' => 'my.update',
+        'uses' => 'MyController@update',
     ]);
 //    充值
-    $api->get('my/recharge', [
+    $api->post('my/recharge', [
         'as' => 'my.recharge',
         'uses' => 'MyController@recharge',
     ]);
@@ -135,10 +127,6 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.reply_my',
         'uses' => 'MyController@replyMy',
     ]);
-    $api->post('my/my_reply', [
-        'as' => 'my.my_reply',
-        'uses' => 'MyController@myReply',
-    ]);
     $api->get('my/dream', [
         'as' => 'my.dream',
         'uses' => 'MyController@dream',
@@ -152,35 +140,11 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.setting',
         'uses' => 'MyController@setting',
     ]);
-    $api->post('my/store_dream', [
-        'as' => 'my.store_dream',
-        'uses' => 'MyController@storeDream',
-    ]);
-
 //    用户信息
-    $api->get('user/index', [
-        'as' => 'user.index',
-        'uses' => 'HomeController@index',
-    ]);
-    $api->get('user/homepage', [
-        'as' => 'user.homepage',
-        'uses' => 'HomeController@homepage',
-    ]);
-    $api->post('user/support', [
-        'as' => 'user.support',
-        'uses' => 'HomeController@support',
+    $api->get('user/show', [
+        'as' => 'user.show',
+        'uses' => 'HomeController@show',
     ]);
-//    互动
-    $api->get('user/interaction', [
-        'as' => 'user.interaction',
-        'uses' => 'HomeController@interaction',
-    ]);
-
-    $api->get('user/paihang', [
-        'as' => 'user.paihang',
-        'uses' => 'HomeController@paihang',
-    ]);
-
 //    梦想
     $api->get('dream/show', [
         'as' => 'dream.show',
@@ -198,8 +162,21 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'dream.support',
         'uses' => 'DreamController@support',
     ]);
-    $api->post('dream/add_info', [
-        'as' => 'dream.add_info',
-        'uses' => 'DreamController@addInfo',
+    $api->post('dream/store', [
+        'as' => 'dream.store',
+        'uses' => 'DreamController@store',
+    ]);
+//    interaction  动态
+    $api->post('interaction/store', [
+        'as' => 'interaction.store',
+        'uses' => 'InteractionController@store',
+    ]);
+    $api->post('interaction/comments', [
+        'as' => 'interaction.comments',
+        'uses' => 'InteractionController@comments',
+    ]);
+    $api->post('interaction/reply', [
+        'as' => 'interaction.reply',
+        'uses' => 'InteractionController@reply',
     ]);
 });