浏览代码

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-manage into develop

zhangchangchun 5 年之前
父节点
当前提交
236aef590c

+ 70 - 5
app/Http/Controllers/Behavior/BehaviorController.php

@@ -28,12 +28,52 @@ class BehaviorController extends Controller
      */
     public function index(Request $request)
     {
-        $bahavior_list = $this->behaviorRepository->index($request->all());
-
-        if ($bahavior_list){
-
-            return $bahavior_list;
+        $behavior_list = $this->behaviorRepository->index($request->all());
+        if (count($behavior_list)>0){
+            foreach ($behavior_list as $k=>$v){
+                if (isset($behavior_list[$k]['_id']) || isset($behavior_list[$k]['behavior_name'])){
+                    $behavior_list[$k]['_id'] = $v['_id'];
+                    $behavior_list[$k]['behavior_name'] = $v['behavior_name'];
+                    $behavior_list[$k]['virus_behavior_id'] = $v['_id'];
+                    $behavior_list[$k]['name'] = $v['behavior_name'];
+                    unset($behavior_list[$k]['_id']);
+                    unset($behavior_list[$k]['behavior_name']);
+                }
+            }
         }
+        $data['data'] = $behavior_list;
+        $data['extra'] = [
+            'filters' => [
+                'virus_behavior_id',
+                'behavior_status',
+                'name',
+            ],
+            'columns' => [
+                'id',
+                'virus_behavior_id',
+                'name',
+                'behavior_level',
+                'behavior_cycle_type',
+                'behavior_action_id',
+                'behavior_cycle',
+                'behavior_binding_users',
+                'physical_strength',
+                'rainbow_beans',
+                'remarks',
+                'is_open',
+                'behavioral_cycle_start_time',
+                'behavioral_cycle_end_time',
+                'allotted_quantity_rule',
+                'behavior_identification',
+                'trigger_times',
+                'effective_trigger',
+                'relative_series',
+                'absolute_progression',
+                'created_at',
+                'updated_at'
+            ]
+        ];
+        return $data;
     }
 
 
@@ -55,9 +95,34 @@ class BehaviorController extends Controller
     //编辑行为
     public function edit(Request $request)
     {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:behavior',
+            'virus_behavior_id' => 'required',
+            'name' => 'required|string',
+            'behavior_level' => 'required|integer',
+            'behavior_cycle_type' => ['required',Rule::in(0, 1)],
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->behaviorRepository->edit($request->all());
 
     }
 
+    //行为管理
+    public function editStatus(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:behavior',
+            'is_open' => ['required', Rule::in(0,1)],
+        ]);
+
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->behaviorRepository->editStatus($request->all());
+    }
+
 
 
 }

+ 52 - 0
app/Http/Controllers/Behavior/LogController.php

@@ -0,0 +1,52 @@
+<?php
+namespace App\Http\Controllers\Behavior;
+use App\Http\Controllers\Controller;
+use App\Repositories\Behavior\BehaviorLogRepository;
+use App\Transformers\Behavior\BehaviorLogTransformer;
+use Illuminate\Http\Request;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/13
+ * Time: 下午7:01
+ */
+
+class LogController extends Controller
+{
+    public function __construct(BehaviorLogRepository $behaviorLogRepository)
+    {
+        $this->behaviorLogRepository = $behaviorLogRepository;
+    }
+
+    //日志列表
+    public function index(Request $request)
+    {
+        $logList = $this->behaviorLogRepository->log($request->all());
+        $fractal = new Manager();
+        $resource = new Collection($logList, new BehaviorLogTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($logList));
+        $data = $fractal->createData($resource)->toArray();
+
+        $data['extra'] = [
+            'filters' => [
+                'type',
+                'created_at',
+            ],
+            'columns' => [
+                'id',
+                'username',
+                'behavior_id',
+                'operator_id',
+                'type',
+                'created_at',
+                'content',
+            ]
+        ];
+        return $data;
+
+    }
+
+}

+ 4 - 1
app/Http/Controllers/ConfigController.php

@@ -118,7 +118,10 @@ class ConfigController extends Controller
             'release_status'=>[
                 '1'=>'正常',
                 '0'=>'异常'
-
+            ],
+            //行为绑定用户
+            'behavior_binding_users'=>[
+                0=>'所有用户'
             ]
         ];
     }

+ 6 - 0
app/Models/Behavior.php

@@ -13,4 +13,10 @@ class Behavior extends Model
 {
     protected $table = 'behavior';
     protected $guarded = [];
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['virus_behavior_id','name','behavior_level','behavior_cycle_type','behavior_action_id','behavior_cycle','is_open'];
+
 }

+ 23 - 0
app/Models/BehaviorOperationLog.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/13
+ * Time: 15:22
+ */
+
+namespace App\Models;
+use Illuminate\Database\Eloquent\Model;
+
+class BehaviorOperationLog extends Model
+{
+    protected $table = 'behavior_operation_log';
+    protected $guarded = [];
+
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['operator_id','behavior_id','username','type','content'];
+
+}

+ 39 - 0
app/Repositories/Behavior/BehaviorLogRepository.php

@@ -0,0 +1,39 @@
+<?php
+namespace App\Repositories\Behavior;
+use App\Models\BehaviorOperationLog;
+
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/13
+ * Time: 下午7:11
+ */
+
+class BehaviorLogRepository
+{
+    public function __construct(BehaviorOperationLog $behaviorOperationLog)
+    {
+        $this->behaviorOperationLog = $behaviorOperationLog;
+    }
+
+    public function log($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
+        $where = [];
+        if(isset($request['type'])){
+            $where[] = ['type', $request['type']];
+        }
+
+        return $this->behaviorOperationLog
+            ->where($where)
+            ->where(function($query) use ($request){
+                if(isset($request['created_at'])){
+                    $time = explode('_', $request['created_at']);
+                    $query->whereBetween('created_at', $time);
+                }
+            })
+            ->orderBy('id','desc')
+            ->paginate($perPage);
+    }
+
+}

+ 170 - 22
app/Repositories/Behavior/BehaviorRepository.php

@@ -1,12 +1,16 @@
 <?php
 namespace App\Repositories\Behavior;
 use App\Models\Behavior;
+use App\Models\BehaviorOperationLog;
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\RequestException;
+use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 use Tymon\JWTAuth\Facades\JWTAuth;
 use Dingo\Api\Http\Response;
 use Symfony\Component\HttpKernel\Exception\HttpException;
+use Illuminate\Database\QueryException;
 
 /**
  * Created by PhpStorm.
@@ -17,9 +21,10 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
 
 class BehaviorRepository
 {
-    public function __construct(Behavior $behavior)
+    public function __construct(Behavior $behavior,BehaviorOperationLog $behaviorOperationLog)
     {
         $this->behavior = $behavior;
+        $this->behaviorOperationLog = $behaviorOperationLog;
         //初始化virus域名
         $this->client = new Client([
             'base_uri' => config('constants.VIRUS_URL'),
@@ -51,6 +56,7 @@ class BehaviorRepository
                 'returnCode' => '-1',
                 'errMsg' => '网络超时'.$exception->getMessage()
             ];
+            Log::debug('获取virus行为列表:'.$exception->getMessage());
         }
         //已登记行为
         $registered_bahavior = $this->behavior->get();
@@ -82,7 +88,7 @@ class BehaviorRepository
         //根据行为ID筛选
         if (isset($request['virus_behavior_id'])){
             foreach ($new_res as $k=>$v){
-                if (isset($v['virus_behavior_id']) && $v['virus_behavior_id'] != $request['virus_behavior_id']){
+                if (isset($v['id']) && $v['id'] != $request['virus_behavior_id']){
                     unset($new_res[$k]);
                     $new_re = array_merge($new_res);
                 }elseif (isset($v['_id']) && $v['_id'] != $request['virus_behavior_id']){
@@ -102,19 +108,19 @@ class BehaviorRepository
             }
             return $new_re;
         }
-        //根据绑定的动作ID筛选
-        if (isset($request['behavior_action_id'])){
-            foreach ($new_res as $key=>$val) {
-                if (isset($val['behavior_action_id']) && ($val['behavior_action_id'] != $request['behavior_action_id'])) {
-                    unset($new_res[$key]);
-                    $new_re = array_merge($new_res);
-                } elseif (!isset($val['behavior_action_id'])) {
-                    unset($new_res[$key]);
-                    $new_re = array_merge($new_res);
-                }
-            }
-            return $new_re;
-        }
+        //根据绑定的动作ID筛选(暂时取消)
+//        if (isset($request['behavior_action_id'])){
+//            foreach ($new_res as $key=>$val) {
+//                if (isset($val['behavior_action_id']) && ($val['behavior_action_id'] != $request['behavior_action_id'])) {
+//                    unset($new_res[$key]);
+////                    $new_re = array_merge($new_res);
+//                } elseif (!isset($val['behavior_action_id'])) {
+//                    unset($new_res[$key]);
+////                    $new_re = array_merge($new_res);
+//                }
+//            }
+//            return $new_re;
+//        }
         //根据行为名称筛选
         if (isset($request['name'])){
             foreach ($new_res as $key => $val) {
@@ -132,11 +138,11 @@ class BehaviorRepository
 
     public function create($request)
     {
-        $behavior_name = $this->behavior->where(['name'=>$request['name']])->first();
-        if($behavior_name){
+        $behavior_name = $this->behavior->where(['name' => $request['name']])->first();
+        if ($behavior_name) {
             return Response::create([
-                'message'  => '该行为已存在',
-                'status_code'   => 500
+                'message' => '该行为已存在',
+                'status_code' => 500
             ]);
         }
         $data = [
@@ -145,7 +151,68 @@ class BehaviorRepository
             'behavior_level' => $request['behavior_level'],
             'behavior_cycle_type' => $request['behavior_cycle_type'],
             'is_open' => 0,
-            'behavior_action_id' => isset($request['behavior_action_id']) ? $request['behavior_action_id'] : 0,
+            'behavior_action_id' => isset($request['behavior_action_id']) ? $request['behavior_action_id'] : '',
+            'behavior_cycle' => isset($request['behavior_cycle']) ? $request['behavior_cycle'] : '',
+            'behavior_binding_users' => isset($request['behavior_binding_users']) ? $request['behavior_binding_users'] : 0,
+            'physical_strength' => isset($request['physical_strength']) ? $request['physical_strength'] : '',
+            'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : '',
+            'remarks' => isset($request['remarks']) ? $request['remarks'] : '',
+            'behavioral_cycle_start_time' => isset($request['behavioral_cycle_start_time']) ? $request['behavioral_cycle_start_time'] : null,
+            'behavioral_cycle_end_time' => isset($request['behavioral_cycle_end_time']) ? $request['behavioral_cycle_end_time'] : null,
+            'allotted_quantity_rule' => isset($request['allotted_quantity_rule']) ? json_encode($request['allotted_quantity_rule']) : '',
+            'behavior_identification' => isset($request['behavior_identification']) ? $request['behavior_identification'] : '',
+            'trigger_times' => isset($request['trigger_times']) ? $request['trigger_times'] : 0,
+            'effective_trigger' => isset($request['effective_trigger']) ? $request['effective_trigger'] : 0,
+            'relative_series' => isset($request['relative_series']) ? $request['relative_series'] : 0,
+            'absolute_progression' => isset($request['absolute_progression']) ? $request['absolute_progression'] : 0,
+        ];
+        DB::beginTransaction();
+        try {
+            $res = $this->behavior->create($data);
+            if ($res) {
+                $token =  JWTAuth::decode(JWTAuth::getToken());
+                $uid = $token['user']->id;
+                $username = $token['user']->username;
+                $cerate_bahavior_data = [
+                    'operator_id' => $uid,
+                    'behavior_id' => $res['id'],
+                    'username' => $username,
+                    'content' => '创建'.$request['name'].'行为',
+                    'type' => 0,
+                    'created_at' => date('Y-m-d H:i:s'),
+                    'updated_at' => date('Y-m-d H:i:s')
+                ];
+                $result = $this->behaviorOperationLog->insert($cerate_bahavior_data);
+                if (!$result) {
+                    throw new HttpException(500, '操作日志记录失败');
+                }
+            }
+            DB::commit();
+            return Response::create();
+
+        } catch (QueryException $exception) {
+            DB::rollBack();
+            Log::debug('注册行为:'.$exception->getMessage());
+            return Response::create([
+                'message' => '添加失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code' => 500
+            ]);
+        }
+    }
+
+    public function edit($request)
+    {
+        $behavior_id = $this->behavior->find($request['id']);
+        if ($behavior_id->is_open == 1){
+            throw new HttpException(500, '无法编辑已经在记录的行为');
+        }
+        $update_bahavior = [
+            'virus_behavior_id' => $request['virus_behavior_id'],
+            'name' => $request['name'],
+            'behavior_level' => $request['behavior_level'],
+            'behavior_cycle_type' => $request['behavior_cycle_type'],
+            'is_open' => 0,
             'behavior_cycle' => isset($request['behavior_cycle']) ? $request['behavior_cycle'] : '',
             'behavior_binding_users' => isset($request['behavior_binding_users']) ? $request['behavior_binding_users'] : 0,
             'physical_strength' => isset($request['physical_strength']) ? $request['physical_strength'] : '',
@@ -159,11 +226,92 @@ class BehaviorRepository
             'effective_trigger' => isset($request['effective_trigger']) ? $request['effective_trigger'] : 0,
             'relative_series' => isset($request['relative_series']) ? $request['relative_series'] : 0,
             'absolute_progression' => isset($request['absolute_progression']) ? $request['absolute_progression'] : 0,
+            'updated_at' => date('Y-m-d H:i:s')
+            ];
+        DB::beginTransaction();
+        try{
+            $res = $this->behavior->where('id',$request['id'])->update($update_bahavior);
+                if ($res) {
+                    $token =  JWTAuth::decode(JWTAuth::getToken());
+                    $uid = $token['user']->id;
+                    $username = $token['user']->username;
+                    $cerate_bahavior_data = [
+                        'operator_id' => $uid,
+                        'behavior_id' => $request['id'],
+                        'username' => $username,
+                        'content' => json_encode($update_bahavior),
+                        'type' => 1,
+                        'created_at' => date('Y-m-d H:i:s'),
+                        'updated_at' => date('Y-m-d H:i:s')
+                    ];
+                    $result = $this->behaviorOperationLog->insert($cerate_bahavior_data);
+                    if (!$result) {
+                        throw new HttpException(500, '操作日志记录失败');
+                    }
+                }
+                DB::commit();
+                return Response::create();
+
+            } catch (QueryException $exception) {
+                DB::rollBack();
+                Log::debug('编辑行为:'.$exception->getMessage());
+                return Response::create([
+                    'message' => '编辑失败,请重试',
+                    'error' => $exception->getMessage(),
+                    'status_code' => 500
+                ]);
+            }
+    }
+
+    public function editStatus($request)
+    {
+        $behavior = $this->behavior->find($request['id']);
+
+        $behavior_array = [
+            'is_open' => $request['is_open'],
+            'updated_at' => date('Y-m-d H:i:s')
         ];
+        if ($request['is_open'] == 0){
+            $is_open = '关闭';
+        }else{
+            $is_open = '开启';
+        }
+        $behavior_name = $behavior->name;
 
-        if (!$this->behavior->create($data)) {
-            throw new HttpException(500, '添加失败,请重试');
+        DB::beginTransaction();
+        try {
+            $res = $behavior->where('id',$request['id'])->update($behavior_array);
+            if ($res) {
+                $token =  JWTAuth::decode(JWTAuth::getToken());
+                $uid = $token['user']->id;
+                $username = $token['user']->username;
+                $cerate_bahavior_data = [
+                    'operator_id' => $uid,
+                    'behavior_id' => $request['id'],
+                    'username' => $username,
+                    'content' => $is_open.'了'.$behavior_name.'行为',
+                    'type' => 2,
+                    'created_at' => date('Y-m-d H:i:s'),
+                    'updated_at' => date('Y-m-d H:i:s')
+                ];
+                $result = $this->behaviorOperationLog->insert($cerate_bahavior_data);
+                if (!$result) {
+                    throw new HttpException(500, '操作日志记录失败');
+                }
+            }
+            DB::commit();
+            return Response::create();
+
+        } catch (QueryException $exception) {
+            DB::rollBack();
+            Log::debug('修改状态行为:' . $exception->getMessage());
+            return Response::create([
+                'message' => '修改状态失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code' => 500
+            ]);
         }
+
     }
 }
 

+ 29 - 2
app/Repositories/Post/PostRepository.php

@@ -15,6 +15,7 @@ use App\Models\PostData;
 use App\Models\PostImgs;
 use App\Models\PostLog;
 use App\Models\Topic;
+use App\Service\RabbitMqUtil;
 use App\Traits\PostTrait;
 use App\Traits\UserTrait;
 use Illuminate\Database\QueryException;
@@ -38,6 +39,7 @@ class PostRepository
                                 PostComment $postComment,
                                 PostImgs $postImgs,
                                 PostLog $postLog,
+                                RabbitMqUtil $rabbitMqUtil,
                                 CategoryTopic $categoryTopic,
                                 Topic $topic)
     {
@@ -46,6 +48,7 @@ class PostRepository
         $this->postComment = $postComment;
         $this->postImgs = $postImgs;
         $this->postLog = $postLog;
+        $this->rabbitMqUtil = $rabbitMqUtil;
         $this->categoryTopic = $categoryTopic;
         $this->topic = $topic;
     }
@@ -107,7 +110,6 @@ class PostRepository
                 'share_count' => 0,
                 'share_real_count' => 0,
                 'comment_count' => 0,
-                'comment_real_count' => 0,
                 'collect_count' => 0,
                 'collect_real_count' => 0,
                 'available_bean' => $this->availableBean(),
@@ -223,6 +225,7 @@ class PostRepository
     {
         //验证小号
         $userInfo = $this->getUserInfo($request['uid']);
+        Log::debug('评论&回复小号'.json_encode($userInfo));
         if(!$userInfo || $userInfo['type'] != 1){
             return Response::create([
                 'message'  => '所选小号信息有误',
@@ -242,6 +245,8 @@ class PostRepository
             'post_id' => $request['post_id'],
             'parent_id' => 0,
             'username' => $userInfo['username'],
+            'reply_uid' => 0,
+            'reply_username' => '',
             'avatar' => $userInfo['avatar'],
             'content' => $request['content'],
             'is_delete' => 0,
@@ -261,12 +266,30 @@ class PostRepository
                 ]);
             }
             $data['parent_id'] = $request['parent_id'];
+            $data['reply_uid'] = $comment->uid;
+            $data['reply_username'] = $comment->username;
+            $this->rabbitMqUtil->push('add_message_one', [
+                'uid' => $comment->uid,
+                'message_show_type' => 'post_reply_main',
+                'param' => [
+                    'uid' => $userInfo['uid'],
+                    'username' => $userInfo['username'],
+                ]
+            ]);
+        }else{
+            $this->rabbitMqUtil->push('add_message_one', [
+                'uid' => $post->uid,
+                'message_show_type' => 'post_comment',
+                'param' => [
+                    'uid' => $userInfo['uid'],
+                    'username' => $userInfo['username'],
+                ]
+            ]);
         }
         DB::beginTransaction();
         try{
             $this->postComment->create($data);
             $post->data->comment_count += 1;
-            $post->data->comment_real_count += 1;
             $post->data->save();
 
             DB::commit();
@@ -300,6 +323,10 @@ class PostRepository
             $where[] = ['type', $request['type']];
         }
 
+        if(isset($request['uid'])){
+            $where[] = ['uid', $request['uid']];
+        }
+
         $sort = 'post.id';
         if(isset($request['sort']) && in_array($request['sort'], ['praise_count', 'share_count', 'pv', 'comment_count', 'create_bean'])){
             $sort = $request['sort'];

+ 26 - 0
app/Transformers/Behavior/BehaviorLogTransformer.php

@@ -0,0 +1,26 @@
+<?php
+namespace App\Transformers\Behavior;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/13
+ * Time: 下午7:26
+ */
+use App\Models\BehaviorOperationLog;
+use League\Fractal\TransformerAbstract;
+
+class BehaviorLogTransformer extends TransformerAbstract
+{
+    public function transform(BehaviorOperationLog $logList)
+    {
+        return [
+            'id' => $logList['id'],
+            'username' => $logList['username'],
+            'behavior_id' => $logList['behavior_id'],
+            'operator_id' => $logList['operator_id'],
+            'type' => $logList['type'],
+            'created_at' => date($logList['created_at']),
+            'content' => $logList['content']
+        ];
+    }
+}

+ 8 - 1
app/Transformers/Post/CommentTransformer.php

@@ -15,13 +15,20 @@ class CommentTransformer extends TransformerAbstract
 {
     public function transform(PostComment $postComment)
     {
+        if($postComment['is_delete']){
+            $content = '该评论已被删除';
+        }elseif($postComment['reply_username']){
+            $content = '回复 @'.subtext($postComment['reply_username'], 6).': '.$postComment['content'];
+        }else{
+            $content = $postComment['content'];
+        }
         return [
             'id' => $postComment['id'],
             'parent_id' => $postComment['parent_id'],
             'uid' => $postComment['uid'],
             'username' => $postComment['username'],
             'avatar' => $postComment['avatar'],
-            'content' => $postComment['is_delete'] == 1 ? '该评论已被删除' : $postComment['content'],
+            'content' => $content,
             'created_at' => Carbon::parse($postComment['created_at'])->toDateTimeString(),
             'is_delete' => $postComment['is_delete'],
         ];

+ 33 - 0
database/migrations/2019_06_13_160051_update_behavior_id_to_behavior_operation_log_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class UpdateBehaviorIdToBehaviorOperationLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('behavior_operation_log', function (Blueprint $table) {
+            $table->string('behavior_id')->nullable()->change();
+            $table->text('content')->nullable()->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('behavior_operation_log', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 33 - 0
database/migrations/2019_06_13_174844_add_comment_id_to_comment_account_record_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddCommentIdToCommentAccountRecordTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('comment_account_record', function (Blueprint $table) {
+            $table->integer('current_comment_id')->nullable()->comment('当前评论ID');
+            $table->integer('superior_comment_id')->nullable()->comment('上级评论ID');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('comment_account_record', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 30 - 0
database/migrations/2019_06_14_090938_drop_comment_real_count_from_post_data.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class DropCommentRealCountFromPostData extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE post_data DROP COLUMN comment_real_count");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('post_data', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 40 - 0
database/migrations/2019_06_14_092948_add_reply_uid_to_table_post_comment.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddReplyUidToTablePostComment extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('post_comment', function (Blueprint $table) {
+            $table->integer('reply_uid')
+                ->default(0)
+                ->after('username')
+                ->comment('回复对象uid');
+
+            $table->string('reply_username', 32)
+                ->default('')
+                ->after('reply_uid')
+                ->comment('回复对象昵称');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('post_data', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 59 - 0
database/migrations/2019_06_14_155026_create_table_feed.php

@@ -0,0 +1,59 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateTableFeed extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('feed', function (Blueprint $table) {
+            $table->bigIncrements('id');
+
+            $table->integer('uid')
+                ->index('uid')
+                ->comment('uid');
+
+            $table->integer('follow_uid')
+                ->comment('关注人uid');
+
+            $table->string('follow_username')
+                ->default('')
+                ->comment('关注人昵称');
+
+            $table->string('follow_avatar')
+                ->default('')
+                ->comment('关注人头像');
+
+            $table->string('type', 32)
+                ->default('post_create')
+                ->comment('类型');
+
+            $table->integer('relate_id')
+                ->default(0)
+                ->comment('相关id');
+
+            $table->string('content', 200)
+                ->default('')
+                ->comment('内容');
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('feed');
+    }
+}

+ 9 - 0
routes/api.php

@@ -93,5 +93,14 @@ $api->version('v1', [
         $api->get('behavior/list', 'BehaviorController@index');
         //登记/注册行为
         $api->post('behavior/create', 'BehaviorController@create');
+        //编辑行为
+        $api->put('behavior/edit', 'BehaviorController@edit');
+        //列表修改行为状态(行为管理)
+        $api->post('behavior/editStatus', 'BehaviorController@editStatus');
+
+        //行为日志列表
+        $api->get('behavior/log', 'LogController@index');
+
     });
+
 });