Browse Source

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

Mike 8 years ago
parent
commit
466b4574b3

+ 110 - 12
server/app/Http/Controllers/Api/V1/HomeController.php

xqd xqd xqd
@@ -191,8 +191,8 @@ class HomeController extends Controller
         }
     }
     /**
-     * @api {post} /api/home/bank_card/update 更新银行卡
-     * @apiDescription 更新银行卡
+     * @api {post} /api/user/interaction 互动
+     * @apiDescription 互动
      * @apiGroup home
      * @apiPermission Passport
      * @apiVersion 0.1.0
@@ -200,25 +200,113 @@ class HomeController extends Controller
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
-     *     "state": true,
-     *     "code": 0,
-     *     "message": "success",
-     *     "data": {
-     *         ....
-     *     }
+     * *"status": true,
+     * "status_code": 0,
+     *"message": "",
+     * "data": {
+     * 评论的梦想
+     * "dream1": [
+     * {
+     * "dream": "1的梦想",
+     * "about": "介绍",
+     *"pic": [
+     * {
+     * "pic": "111",
+     * }
+     * ],
+     *  "user": [
+     *{
+     * "pic": "",
+     *],
+     * "comments": [
+     * {
+     * "level": 0,
+     * "content": "EST",
+     * "created_at": "2017-04-27 12:17:20",
+     * }
+     * ],
+     *  * 回复的梦想
+     *  "dream2": [
+     *  {
+     ** "level": 0,
+     *"content": "EST",
+     * "created_at": "2017-04-27 12:17:20",
+     * "updated_at": null,
+     * "deleted_at": null,
+     * "reply_dream": {
+     *  * "dream": "1的梦想",
+     * "about": "介绍",
+     *"time": 0,
+     * "dream_imgs": [
+     *  {
+     *  "pic": "111",
+     *  },
+     *  ]
+     *  },
+     * "reply_dream_pic": [
+     * {
+     * "pic": "111",
+     *  }
+     *  ],
+     *  "reply_created_at": {
+     * "date": "2017-06-13 02:26:31.000000",
+     * "timezone_type": 3,
+     *  "timezone": "UTC"
+     *  },
+     *  "reply_content": "haha",
+     * "reply_level": 0,
+     *   "dream": {
+     * "dream": "1的梦想",
+     * "about": "介绍",
+     * "money": 5000,
+     * "time": 0,
+     * "dream_imgs": [
+     * {
+     * "pic": "111",
+     * },
+     * ]
+     * }
+     *   }
+     *  ]
+     *  }
      * }
      * @apiErrorExample {json} Error-Response:
      *HTTP/1.1 400 Bad Request
      * {
-     *     "state": false,
-     *     "code": 1000,
-     *     "message": "传入参数不正确",
-     *     "data": null or []
+     * "status": false,
+     * "status_code": 1500,
+     * "message": "会员不存在",
+     * "data": null
      * }
      */
     public function interaction(Request $request)
     {
+        $user_id = $request->user_id;
+        $user = UserInfoModel::find($user_id);
+        if (count($user) == 0) return $this->error(ErrorCode::MEMBER_NOT_EXIST);
+//        参与的评论与回复 梦想
+        $dream1 = $user->comDream;
+
+        foreach ($dream1 as $item){
+            $item->pic = $item->dreamImgs;
+            $item->user = $item->dreamUser;
+            $item->comments = $item->DreamInfo;
+            $item->created_at = $item->pivot->created_at;
+            $item->content = $item->pivot->content;
+            $item->level = $item->pivot->level;
+        }
+
+        $dream2 = $user->replyDream;
 
+        foreach ($dream2 as $comment) {
+            $comment->reply_dream = $comment->dream;
+            $comment->reply_dream_pic = $comment->dream->dreamImgs;
+            $comment->reply_created_at = $comment->pivot->created_at;
+            $comment->reply_content = $comment->pivot->content;
+            $comment->reply_level = $comment->pivot->level;
+        }
+
+        return $this->api(compact('dream1','dream2'));
     }
     /**
      * @api {post} /api/home/bank_card/update 更新银行卡
@@ -248,6 +336,16 @@ class HomeController extends Controller
      */
     public function paihang(Request $request)
     {
+//      获取支持过用户的人
+        $user_id = $request->user_id;
+        $user = UserInfoModel::find($user_id);
+        if (count($user) == 0) return $this->error(ErrorCode::MEMBER_NOT_EXIST);
+        $dreams = $user->UserDream;
+        $arr = [];
+        foreach ($dreams as $dream) {
+            $arr[] = $dream->systemInfo;
+        }
+        return $arr;
 
     }
 }

+ 3 - 2
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd
@@ -20,7 +20,7 @@ class MyController extends Controller
      *  "status_code": 0,
      *  "message": "",
      *  "data": {
-     *  "my_care_num": 4,关注
+     *      "my_care_num": 4,关注
      *  "my_fens_num": 3,粉丝
      *  "my_collection_num": 2,收藏
      *  "my_dream_num": 1,发帖
@@ -416,8 +416,9 @@ class MyController extends Controller
             $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');
-            $ok = UserDream::create($data1);
             $arr = $request->pic;
+            if (empty($arr))   return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
+            $ok = UserDream::create($data1);
             $arr1 = [];
             if ($ok) {
                 if (is_array($arr)) {

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

xqd
@@ -16,7 +16,7 @@ class BaseSettingsModel extends BaseModel
      * @var string
      *
      */
-    protected $table = 'base_settings_info';
+    protected $table = 'base_settings';
     /**
     主键
      */

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

xqd
@@ -18,4 +18,9 @@ class CommentInfoModel extends Model
     {
         return $this->belongsTo('App\Models\UserInfoModel','user_id','id');
     }
+
+    public function dream()
+    {
+        return $this->hasOne('App\Models\DreamInfoModel','id','dream_id');
+    }
 }

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

xqd
@@ -65,5 +65,10 @@ class DreamInfoModel extends BaseModel
         return $this->hasOne('App\Models\dreamImages','dream_id','id');
     }
 
+//    支持过的梦想
+    public function systemInfo()
+    {
+        return $this->hasMany('App\Models\SystemInfoModel','other_id','id');
+    }
 
 }

+ 15 - 4
server/app/Models/UserInfoModel.php

xqd
@@ -62,29 +62,40 @@ class UserInfoModel extends Authenticatable
     {
         return $this->belongsToMany('App\Models\UserInfoModel','system_info','other_id','user_id')->withPivot('coin');
     }
-
+//用户梦想
     public function UserDream()
     {
         return $this->belongsToMany('App\Models\DreamInfoModel','user_dream','user_id','dream_id');
     }
-
+//支持的梦想
     public function supDream()
     {
         return $this->belongsToMany('App\Models\DreamInfoModel','system_info','user_id','other_id');
     }
-
+//评论的梦想
+    public function comDream()
+    {
+        return $this->belongsToMany('App\Models\DreamInfoModel','comments_info','user_id','dream_id')->withPivot('content', 'level','created_at');
+    }
+//关注的用户
     public function myCareNum()
     {
         return $this->hasMany('App\Models\UserCareUser','user_id','id');
     }
-
+//关注我的用户
     public function myFens()
     {
         return $this->hasMany('App\Models\UserCareUser','other_user_id','id');
     }
+//    我的收藏
     public function myCollection()
     {
         return $this->hasMany('App\Models\UserCareDream','user_id','id');
     }
+//    回复的梦想
+    public function replyDream()
+    {
+        return $this->belongsToMany('App\Models\CommentInfoModel','reply_comments_info','user_id','comment_id')->withPivot('content', 'level','created_at');
+    }
 
 }

+ 0 - 0
server/database/migrations/2017_05_30_203524_create_base_settings_table.php → server/database/migrations/2017_05_30_203523_create_base_settings_table.php


+ 1 - 1
server/routes/api.php

xqd
@@ -146,7 +146,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'uses' => 'HomeController@support',
     ]);
 //    互动
-    $api->post('user/interaction', [
+    $api->get('user/interaction', [
         'as' => 'user.interaction',
         'uses' => 'HomeController@interaction',
     ]);