gq 8 лет назад
Родитель
Сommit
699e69f57b
18 измененных файлов с 59 добавлено и 219 удалено
  1. 6 6
      server/app/Http/Controllers/Api/V1/AuthController.php
  2. 3 3
      server/app/Http/Controllers/Api/V1/DreamController.php
  3. 2 0
      server/app/Http/Controllers/Api/V1/IndexController.php
  4. 22 3
      server/app/Http/Controllers/Api/V1/MyController.php
  5. 5 0
      server/app/Models/InteractionInfo.php
  6. 1 1
      server/app/Models/UserInfoModel.php
  7. 8 5
      server/database/migrations/2017_06_01_091444_create_user_info_table.php
  8. 7 3
      server/database/migrations/2017_06_02_044138_create_dream_info_table.php
  9. 1 1
      server/database/migrations/2017_06_02_062004_create_reply_comments_info_table.php
  10. 1 1
      server/database/migrations/2017_06_03_035722_create_user_care_dream_table.php
  11. 2 1
      server/database/migrations/2017_06_03_035722_create_user_care_user_table.php
  12. 0 32
      server/database/migrations/2017_06_05_071703_altercol_to_user_care_user_table.php
  13. 0 32
      server/database/migrations/2017_06_15_082636_add_column_video_to_dream_info_table.php
  14. 0 33
      server/database/migrations/2017_06_19_152544_add_column_score_to_dream_info.php
  15. 0 32
      server/database/migrations/2017_06_20_135741_add_dream_num_to_user_care_user.php
  16. 0 33
      server/database/migrations/2017_06_21_173414_add_birthday_city_to_user_info.php
  17. 1 1
      server/database/migrations/2017_06_22_083956_create_support_dream_table.php
  18. 0 32
      server/database/migrations/2017_06_22_085329_add_user_id_to_dream_info.php

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

xqd
@@ -90,15 +90,15 @@ class AuthController extends Controller
         $password = 123456;
 //        if ($request->verify_code != $code)
 //            return $this->error(ErrorCode::SERVICE_CODE_FAILED);
-        $a = UserInfoModel::where('tel',$phone)->first();
-        if (count($a) == 0) {
-            UserInfoModel::create(['tel'=>$phone,'password'=>bcrypt(123456)]);
+        $user = UserInfoModel::where('phone',$phone)->first();
+        if (empty($user)) {
+            UserInfoModel::create(['phone'=>$phone,'password'=>bcrypt(123456)]);
         }
-        $status = UserInfoModel::where('tel',$phone)->first()->status;
+        $status =empty($user) ? 0 : $user->status;
         if ($status == 0) return $this->error(ErrorCode::LOCK_USER);
-        if (Auth::attempt(['tel'=>$phone,'password'=>$password])) {
+        if (Auth::attempt(['phone'=>$phone,'password'=>$password])) {
             $user = Auth::user();
-            $token = $user->createToken($user->tel)->accessToken;
+            $token = $user->createToken($user->phone)->accessToken;
             return $this->api(compact( 'user', 'code','token'));
         }else{
             return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);

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

xqd
@@ -55,9 +55,9 @@ class DreamController extends Controller
      *              "pic": "http://w17.9026.com/img/banner/banner_3.png"
      *          }
      *     ],
-     *      "arr": {                            支持者前三(user_idh和头像)
-     *         "1": "http://www.wsfjq.com/photos/bd119684755.jpg",
-     *           "6": "http://www.wsfjq.com/photos/bd119684755.jpg"
+     *      "arr": {                            支持者前三(user_id和头像)
+     *         "6": "http://www.wsfjq.com/photos/bd119684755.jpg",
+     *           "1": "http://www.wsfjq.com/photos/bd119684755.jpg"
      *      }
      *       "money" : "1000"    用户余额
      *       "score" : "1000"    梦想分数

+ 2 - 0
server/app/Http/Controllers/Api/V1/IndexController.php

xqd
@@ -196,9 +196,11 @@ class IndexController extends Controller
         $type = $request->type;
         if ($type == 'trend') {
             $dreams = DreamInfoModel::orderBy('score','desc')->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);
+            $this->dreams($dreams);
             return $this->api(compact('users','dreams'));
         } else{
             $banner = $this->getBanner();

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

xqd xqd xqd
@@ -311,10 +311,17 @@ class MyController extends Controller
      */
     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 = [];
@@ -443,7 +450,8 @@ class MyController extends Controller
     public function collection()
     {
         $user = $this->getUser();
-        return $this->api(compact('user'));
+        $data = $user->myCollection;
+        return $this->api(compact('data'));
     }
 
     /**
@@ -454,13 +462,24 @@ 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": {
+     *           "key": "2511789",               电话
+     *           "value": "关于喵喵介绍"          介绍
+     *       }
+     *   }
+     *}
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      */
     public function setting()
     {
-        $user = $this->getUser();
-        return $this->api(compact('user'));
+        $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
+        return $this->api(compact('data'));
     }
 
     /**

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

xqd
@@ -24,4 +24,9 @@ class InteractionInfo extends Model
     {
         return $this->hasMany('App\Models\CommentInfoModel','interaction_id','id');
     }
+
+    public function dream()
+    {
+        return $this->belongsTo('App\Models\DreamInfoModel','dream_id','id');
+    }
 }

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

xqd
@@ -98,7 +98,7 @@ class UserInfoModel extends Authenticatable
 //    我的收藏
     public function myCollection()
     {
-        return $this->hasMany('App\Models\UserCareDream','user_id','id');
+        return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id');
     }
 //    回复的梦想
     public function replyDream()

+ 8 - 5
server/database/migrations/2017_06_01_091444_create_user_info_table.php

xqd
@@ -19,18 +19,21 @@ class CreateUserInfoTable extends Migration
     {
         Schema::create('user_info', function (Blueprint $table) {
             $table->increments('id')->comment('用户ID');
-            $table->char('tel',11)->unique()->comment('电话');
+            $table->char('phone',11)->unique()->comment('电话');
             $table->string('password',100)->default('')->comment('密码');
             $table->string('nickname',100)->default('')->comment('昵称');
-            $table->string('pic',100)->default('')->comment('用户头像');
+            $table->string('avatar',100)->default('')->comment('用户头像');
+            $table->date('birthday')->default('2000-06-21');
             $table->integer('sign')->default(0)->comment('用户标签');
-            $table->integer('money')->default(0)->comment('梦想币余额');
+            $table->integer('money')->default(0)->comment('现金余额');
+            $table->integer('coin')->default(0)->comment('梦想币余额');
             $table->tinyInteger('sex')->default(1)->comment('性别');
             $table->string('signture',200)->default('')->comment('个性签名');
-            $table->string('tall',20)->default('')->comment('身高');
-            $table->string('job',20)->default('')->comment('职业');
+            $table->integer('height')->default(0)->comment('身高');
+            $table->string('work',20)->default('')->comment('职业');
             $table->tinyInteger('emotion')->default(1)->comment('情感状态');
             $table->string('address')->default('')->comment('省市区地址');
+            $table->string('city')->comment('城市')->default('');
             $table->string('detail_address')->default('')->comment('详细地址');
             $table->tinyInteger('status')->default(1)->comment('状态');
             $table->string('wechat')->default('')->comment('微信id');

+ 7 - 3
server/database/migrations/2017_06_02_044138_create_dream_info_table.php

xqd
@@ -15,13 +15,17 @@ class CreateDreamInfoTable extends Migration
     {
         Schema::create('dream_info', function (Blueprint $table) {
             $table->increments('id')->comment('id');
-            $table->string('dream',20)->comment('梦想名称');
+            $table->integer('user_id')->comment('用户ID');
+            $table->string('name',20)->comment('梦想名称');
             $table->text('about')->comment('梦想介绍');
-            $table->integer('money')->default(0)->comment('所需梦想币');
+            $table->integer('coin')->default(0)->comment('所需梦想币');
             $table->integer('time')->default(0)->comment('梦想倒计时');
-            $table->integer('get_money')->default(0)->comment('获得梦想币');
+            $table->integer('get_coin')->default(0)->comment('获得梦想币');
             $table->integer('mark')->default(0)->comment('梦想分');
             $table->tinyInteger('status')->default(0)->comment('梦想状态');
+            $table->string('video')->comment('梦想视频地址')->nullable();
+            $table->integer('score')->comment('梦想排行分数')->default(0);
+            $table->string('sign')->comment('梦想标签')->default('');
             $table->timestamps();
             $table->softDeletes();
         });

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

xqd
@@ -15,8 +15,8 @@ class CreateReplyCommentsInfoTable extends Migration
     {
         Schema::create('reply_comments_info', function (Blueprint $table) {
             $table->increments('id');
-            $table->integer('comment_id')->comment('评论ID');
             $table->integer('user_id')->comment('当前登录用户ID');
+            $table->integer('comment_id')->comment('评论ID');
             $table->tinyInteger('level')->default(0)->comment('回复星级');
             $table->text('content')->comment('回复内容');
             $table->timestamps();

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

xqd
@@ -15,7 +15,7 @@ class CreateUserCareDreamTable extends Migration
     {
         Schema::create('user_care_dream', function (Blueprint $table) {
             $table->increments('id');
-            $table->integer('user_id')->comment('用户ID');
+            $table->integer('user_id')->comment('当前用户ID');
             $table->integer('dream_id')->comment('关注梦想ID');
             $table->integer('dream_user_id')->comment('梦想用户ID');
             $table->integer('interaction_number')->comment('最新动态数量');

+ 2 - 1
server/database/migrations/2017_06_03_035722_create_user_care_user_table.php

xqd
@@ -16,7 +16,8 @@ class CreateUserCareUserTable extends Migration
         Schema::create('user_care_user', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id')->comment('当前用户ID');
-            $table->integer('dream_id')->comment('被关注的用户ID');
+            $table->integer('other_user_id')->comment('被关注的用户ID');
+            $table->integer('dream_number')->comment('被关注用户最新梦想数目')->default(0);
             $table->timestamps();
         });
     }

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

xqd
@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AltercolToUserCareUserTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('user_care_user', function ($table) {
-            $table->renameColumn('dream_id', 'other_user_id');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('user_care_user', function (Blueprint $table) {
-            //
-        });
-    }
-}

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

xqd
@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddColumnVideoToDreamInfoTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('dream_info', function (Blueprint $table) {
-            $table->string('video')->comment('梦想视频地址')->nullable()->after('about');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('dream_info', function (Blueprint $table) {
-            //
-        });
-    }
-}

+ 0 - 33
server/database/migrations/2017_06_19_152544_add_column_score_to_dream_info.php

xqd
@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddColumnScoreToDreamInfo extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('dream_info', function (Blueprint $table) {
-            $table->integer('score')->comment('梦想排行分数')->default(0)->after('status');
-            $table->string('sign')->comment('梦想标签')->default('')->after('about');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('dream_info', function (Blueprint $table) {
-            //
-        });
-    }
-}

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

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

+ 0 - 33
server/database/migrations/2017_06_21_173414_add_birthday_city_to_user_info.php

xqd
@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddBirthdayCityToUserInfo extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('user_info', function (Blueprint $table) {
-            $table->date('birthday')->default('2017-06-21')->after('address');
-            $table->string('city')->comment('城市')->default('')->after('address');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('user_info', function (Blueprint $table) {
-            //
-        });
-    }
-}

+ 1 - 1
server/database/migrations/2017_06_22_083956_create_support_dream_info_table.php → server/database/migrations/2017_06_22_083956_create_support_dream_table.php

xqd
@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
-class CreateSupportDreamInfoTable extends Migration
+class CreateSupportDreamTable extends Migration
 {
     /**
      * Run the migrations.

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

xqd
@@ -1,32 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddUserIdToDreamInfo extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('dream_info', function (Blueprint $table) {
-            $table->integer('user_id')->comment('用户ID')->after('id');
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::table('dream_info', function (Blueprint $table) {
-            //
-        });
-    }
-}