gq преди 8 години
родител
ревизия
dbc933cca0
променени са 1 файла, в които са добавени 61 реда и са изтрити 45 реда
  1. 61 45
      server/app/Http/Controllers/Api/V1/IndexController.php

+ 61 - 45
server/app/Http/Controllers/Api/V1/IndexController.php

xqd xqd xqd xqd xqd
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\V1;
 use App\Models\BaseSettingsModel;
 use App\Models\DreamInfoModel;
 use App\Models\SearchInfoModel;
+use App\Models\UserCareDream;
 use App\Models\UserCareUser;
 use App\Models\UserDream;
 use App\Models\UserInfoModel;
@@ -79,6 +80,7 @@ class IndexController extends Controller
      *              },
      *          ],
      *          "http://www.wsfjq.com/photos/bd119684755.jpg"            用户头像
+     *           3                                      新消息条数
      *      ],
      *}
      *      "dreams": {                             梦想列表
@@ -189,7 +191,7 @@ class IndexController extends Controller
         }
         foreach ($arr1 as $k => $v){
             $a = UserInfoModel::find($k);
-            $users[$k] =[$a->allInteraction,$a->pic] ;
+            $users[$k] =[$a->allInteraction,$a->pic,$v] ;
         }
         $type = $request->type;
         if ($type == 'trend') {
@@ -414,52 +416,67 @@ class IndexController extends Controller
      *  "status_code": 0,
      *  "message": "",
      *  "data": [
-     *       {                                梦想信息
-     *           "id": 7,
-     *           "user_id": 2,
-     *           "dream": "梦想标1123",
-     *          "about": "梦想烧1111213",
-     *          "video": "",
-     *          "money": 10000,
-     *           "time": 720000,
-     *          "get_money": 0,
-     *           "status": 0,
-     *          "updated_at": "2017-06-22 09:47:03",
-     *          "dream_imgs": [                梦想的所有图片
+     *      {
+     *          "id": 1,
+     *          "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:14",
+     *          "updated_at": "2017-06-22 21:09:14",
+     *          "deleted_at": null,
+     *          "user_id": 2,
+     *          "comments": [
      *              {
-     *                   "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": 1,
-     *                   "level": 0,
-     *                  "content": "不错的梦想",
-     *                   "updated_at": null,
+     *                  "interaction_id": 1,
+     *                  "user_id": 2,
+     *                  "level": 0,
+     *                  "content": "EST评论",
+     *                  "updated_at": null,
      *                  "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",
-     *                   "replay": [               回复内容
-     *                       {
-     *                          "user_id": 1,
+     *                 "replay": [
+     *                      {
+     *                          "user_id": 2,
      *                          "level": 0,
-     *                          "content": "我也觉得不错",
+     *                           "content": "拉了",
      *                          "updated_at": null,
      *                          "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
      *                      },
      *                      {
-     *                          "user_id": 6,
+     *                          "user_id": 3,
      *                          "level": 0,
-     *                          "content": "祝你梦想成真",
+     *                          "content": "userid3回复了你的消息",
      *                          "updated_at": null,
      *                          "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
-     *                       }
+     *                      }
      *                  ]
-     *              }
-     *          ],
+     *                  },
+     *                  {
+     *                  "interaction_id": 1,
+     *                  "user_id": 6,
+     *                  "level": 0,
+     *                  "content": "梦想ID1的第二条评论",
+     *                 "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"
+     *                          }
+     *                  ]
+     *             }
+     *          ]
      *      },
      *  ]
      *}
@@ -472,16 +489,15 @@ class IndexController extends Controller
         $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 = DreamInfoModel::where('user_id',$other_id)->orderBy('id','desc')->get();
-            foreach ($data as $item) {
-            $item->dream_imgs =  $item->dreamImgs ;
-            $item->comments = $item->DreamInfo;
-            foreach ( $item->comments as $k => $v){
-                $v->pic =  UserInfoModel::find($v->user_id)->pic;
+        UserCareDream::where('user_id',$user->id)->where('dream_user_id',$other_id)->update(['interaction_number'=>0]);
+        $data = UserInfoModel::find($other_id)->allInteraction;
+        foreach ($data as $item) {
+            $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;
+                foreach ($v->replay as $k1 => $v1) {
+                    $v1->pic = UserInfoModel::find($v1->user_id)->pic;
                 }
             }
         }