gq 8 år sedan
förälder
incheckning
d2cd9d6a4a

+ 67 - 50
server/app/Http/Controllers/Api/V1/IndexController.php

xqd xqd xqd
@@ -306,24 +306,24 @@ class IndexController extends Controller
      * @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": "",  梦想图片
-                }
-            ]
-        }
-    }
+     *{
+     *   "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
      */
@@ -372,37 +372,46 @@ class IndexController extends Controller
      * @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",   梦想图片
-                    },
-                ],
-            }
-        ]
-    }
+     *{
+     *   "status": true,
+     *   "status_code": 0,
+     *  "message": "",
+     *   "data": [
+     *       {
+     *          "dream": "1的梦想",
+     *          "about": "介绍",
+     *          "video": "",
+     *          "time": 0,
+     *           "status": 0,
+     *          "updated_at": null,
+     *           "dream_imgs": [
+     *              {
+     *                  "title": "1",    梦想图片介绍
+     *                  "pic": "111",    梦想图片
+     *              },
+     *          ],
+     *           "comments": [
+     *              {
+     *                  "user_id": 2,
+     *                  "level": 0,
+     *                  "content": "评论内容",       评论内容
+     *                  "updated_at": null,
+     *                  "pic": "",         评论者头像
+     *                  "replay": [
+     *                       {
+     *                          "level": 0,
+     *                          "content": "回复内容",   回复内容
+     *                          "updated_at": null,
+     *                          "pic": ""               回复者头像
+     *                      }
+     *                  ]
+     *              }
+     *          ],
+     *          }
+     *          ]
+     *     }
+     *   ]
+     *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      */
@@ -415,7 +424,15 @@ class IndexController extends Controller
         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 ;
+            $item->dream_imgs =  $item->dreamImgs ;
+            $item->comments = $item->DreamInfo;
+            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);
     }

+ 7 - 0
server/app/Models/CommentInfoModel.php

xqd xqd
@@ -13,6 +13,8 @@ class CommentInfoModel extends Model
         'level',
         'content',
     ];
+    protected $hidden = ['dream_id','created_at','deleted_at','id'];
+
 
     public function CommentUser()
     {
@@ -23,4 +25,9 @@ class CommentInfoModel extends Model
     {
         return $this->hasOne('App\Models\DreamInfoModel','id','dream_id');
     }
+
+    public function replay()
+    {
+        return $this->hasMany('App\Models\ReplyCommentsInfo','comment_id','id');
+    }
 }

+ 1 - 0
server/app/Models/DreamImages.php

xqd
@@ -8,4 +8,5 @@ class DreamImages extends Model
 {
     protected $table = 'dream_images';
     protected $fillable = ['dream_id','title','pic'];
+    protected $hidden = ['dream_id','created_at','updated_at','deleted_at','id'];
 }

+ 3 - 0
server/app/Models/DreamInfoModel.php

xqd
@@ -40,6 +40,9 @@ class DreamInfoModel extends BaseModel
                            'status'
                           ];
 
+    protected $hidden = ['score','created_at','deleted_at','id','sign','money','mark','get_money'];
+
+
     public function dreamUser()
     {
         return $this->belongsToMany('App\Models\UserInfoModel','user_dream','dream_id','user_id');

+ 2 - 0
server/app/Models/ReplyCommentsInfo.php

xqd
@@ -14,5 +14,7 @@ class ReplyCommentsInfo extends Model
         'content',
         'level',
     ] ;
+    protected $hidden = ['comment_id','created_at','deleted_at','id'];
+
 
 }