Parcourir la source

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

zhangchangchun il y a 5 ans
Parent
commit
3c27ce3a0c

+ 197 - 0
app/Console/Commands/VirusAdd.php

@@ -0,0 +1,197 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/24
+ * Time: 9:52
+ */
+namespace App\Console\Commands;
+
+
+use GuzzleHttp\Exception\RequestException;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
+use PhpAmqpLib\Connection\AMQPStreamConnection;
+use GuzzleHttp\Client;
+
+class VirusAdd extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'virus:add';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'virus添加数据';
+
+    protected $channel;
+    protected $connection;
+
+    protected $queue = 'virus_add';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->connection = $this->getConnection();
+        $this->channel = $this->connection->channel();
+        $this->channel->exchange_declare($this->queue, 'fanout', false, true, false);
+
+    }
+
+    public function getConnection()
+    {
+        $conn = false;
+        if ($this->connection) {
+            return $this->connection;
+        }
+        for ($i = 0; $i < 3; $i++) {
+            $connection = $this->createConn();
+            if ($connection) {
+                $conn = $connection;
+                break;
+            }
+            Log::info("create amqp conn retry=" . $i);
+        }
+        return $conn;
+    }
+
+    public function createConn()
+    {
+        try {
+            $connection = new AMQPStreamConnection(env('MQ_HOST'), env('MQ_PORT'), env('MQ_USERNAME'), env('MQ_PWD'), env('MQ_VHOST'));
+        } catch (\Exception $exception) {
+            Log::info("AMQP connection Error" . $exception->getMessage());
+            $connection = false;
+        }
+        return $connection;
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $queue_name = $this->queue;
+        $this->channel->queue_declare($queue_name, false, true, false, false);
+        $this->channel->queue_bind($queue_name, $this->queue);
+        $callback = function ($msg) {
+            $this->line(date('Y-m-d H:i:S').$msg->body);
+            $data = \GuzzleHttp\json_decode($msg->body, true);
+            $this->line('接收一条消息收到数据' . $msg->body);
+            $res = $this->send($data);
+            if ($res) {
+                $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
+            }
+        };
+        $this->channel->basic_consume($queue_name, '', false, false, false, false, $callback);
+
+        while (count($this->channel->callbacks)) {
+            $this->channel->wait();
+        }
+        $this->channel->close();
+        $this->connection->close();
+
+
+    }
+
+    private function send($data)
+    {
+        // 初始化virus域名
+        $client = new Client([
+            'timeout' => 3
+        ]);
+        try {
+            // 签名设置
+            $signKey = [
+                'app_id' => config('customer.VIRUS_APP_ID'),
+                'behavior_id' => $data['behavior_id'],
+                'target_id' => (string) $data['target_id'],
+                'action_id' => (string) $data['action_id'],
+                'behavior_flag' => $data['behavior_flag']
+            ];
+            ksort($signKey);
+            $signKey = urldecode(http_build_query($signKey));
+            $sign = md5(config('customer.VIRUS_APP_SECRET') . $signKey);
+            Log::debug('签名:'.$sign);
+            $json = [];
+            if($data['behavior_flag'] == 'publish'){
+                $json = [
+                    'sign' => $sign,
+                    'app_id' => config('customer.VIRUS_APP_ID'),
+                    'behavior_id' => $data['behavior_id'],
+                    'behavior_flag' => $data['behavior_flag'],
+                    'post_id' => $data['post_id'],
+                    'post_desc' => $data['post_desc'],
+                    'post_cover' => $data['post_cover'],
+                    'target_id' => (string) $data['target_id'],
+                    'action_id' => (string) $data['action_id'],
+                    'extra' => [],
+                ];
+            }elseif($data['behavior_flag'] == 'comment'){
+                $json = [
+                    'sign' => $sign,
+                    'app_id' => config('customer.VIRUS_APP_ID'),
+                    'behavior_id' => $data['behavior_id'],
+                    'behavior_flag' => $data['behavior_flag'],
+                    'post_id' => $data['post_id'],
+                    'post_author_uid' => $data['post_author_uid'],
+                    'post_desc' => $data['post_desc'],
+                    'post_cover' => $data['post_cover'],
+                    'comment_id' => $data['comment_id'],
+                    'comment_content' => $data['comment_content'],
+                    'parent_comment_id' => $data['parent_comment_id'],
+                    'parent_comment_content' => $data['parent_comment_content'],
+                    'parent_comment_uid' => $data['parent_comment_uid'],
+                    'parent_comment_time' => $data['parent_comment_time'],
+                    'reply_uid' => $data['reply_uid'],
+                    'reply_username' => $data['reply_username'],
+                    'target_id' => (string) $data['target_id'],
+                    'action_id' => (string) $data['action_id'],
+                    'extra' => [],
+                ];
+            }elseif(in_array($data['behavior_flag'], ['read', 'like', 'collect', 'forward'])){
+                $json = [
+                    'sign' => $sign,
+                    'app_id' => config('customer.VIRUS_APP_ID'),
+                    'behavior_id' => $data['behavior_id'],
+                    'behavior_flag' => $data['behavior_flag'],
+                    'behavior_value' => $data['behavior_value'],
+                    'post_id' => $data['post_id'],
+                    'post_author_uid' => $data['post_author_uid'],
+                    'post_desc' => $data['post_desc'],
+                    'post_cover' => $data['post_cover'],
+                    'target_id' => (string) $data['target_id'],
+                    'action_id' => (string) $data['action_id'],
+                    'extra' => [],
+                ];
+            }else{
+                Log::debug('行为类型错误'.json_encode($data));
+                return true;
+            }
+
+            $response = $client->request('POST', config('customer.VIRUS_URL').'/v2/record/add', [
+                'headers' => [
+                    'Content-Type' => 'application/json'
+                ],
+                'json' => $json
+            ]);
+            Log::debug('virus添加数据成功:'.$response->getBody()->getContents());
+            return true;
+        } catch (RequestException $e) {
+            Log::debug('virus添加数据失败:'.$e->getMessage());
+        }
+    }
+}

+ 2 - 0
app/Console/Kernel.php

@@ -6,6 +6,7 @@ use App\Console\Commands\Apollo;
 use App\Console\Commands\Downloads;
 use App\Console\Commands\PostStatistics;
 use App\Console\Commands\PostYesterday;
+use App\Console\Commands\VirusAdd;
 use Illuminate\Console\Scheduling\Schedule;
 use Laravel\Lumen\Console\Kernel as ConsoleKernel;
 
@@ -20,6 +21,7 @@ class Kernel extends ConsoleKernel
         Apollo::class,
         PostYesterday::class,
         Downloads::class,
+        VirusAdd::class,
         PostStatistics::class
     ];
 

+ 2 - 0
app/Helper/helper.php

@@ -46,6 +46,7 @@ function http($url, $param, $isCheck = true, $method = 'post')
         $client = new \GuzzleHttp\Client();
         $response = $client->request($method, $url, $param);
         $result = json_decode($response->getBody()->getContents(), true);
+        \Illuminate\Support\Facades\Log::debug('url:'.$url.'param:'.json_encode($param).'response:'.json_encode($result));
         if ($isCheck == true) {
             if ($result['code'] == 0) {
                 return $result['data'];
@@ -57,6 +58,7 @@ function http($url, $param, $isCheck = true, $method = 'post')
         }
 
     } catch (\Exception $exception) {
+        \Illuminate\Support\Facades\Log::debug('http-exception:'.$exception->getMessage());
         return [];
     }
 }

+ 81 - 0
app/Http/Controllers/AliYunVodController.php

@@ -0,0 +1,81 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-06-15
+ * Time: 10:53
+ */
+
+namespace App\Http\Controllers;
+
+
+use App\Service\AliYunVodService;
+use function GuzzleHttp\Psr7\str;
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Validator;
+use ShaoZeMing\AliVod\SDK\GetPlayInfoRequest;
+use ShaoZeMing\AliVod\Services\UploadService;
+use ShaoZeMing\Aliyun\Core\DefaultAcsClient;
+use ShaoZeMing\Aliyun\Core\Profile\DefaultProfile;
+
+class AliYunVodController extends Controller
+{
+    public function __construct(AliYunVodService $aliYunVodService)
+    {
+        $this->aliYunVodService = $aliYunVodService;
+    }
+
+    /**
+     * 获取视频上传凭证信息
+     * @param Request $request
+     * @return array
+     * @throws \ShaoZeMing\Aliyun\Core\Exception\ClientException
+     * @throws \ShaoZeMing\Aliyun\Core\Exception\ServerException
+     */
+    public function getVodUploadAuth(Request $request)
+    {
+        $request = $request->all();
+        $validator = Validator::make($request, [
+            'title' => 'required',
+            'filename' => 'required'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(),500);
+        }
+        $instance = new UploadService(config('aliyunvod'));
+        $title = $request['title'];
+        $filename = $request['filename'];
+        $coverUrl = isset($request['cover_url']) ?$request['cover_url']:'';
+        try {
+            $result = $instance->createUploadVideo($title, $filename, '', $coverUrl);  //获取视频上传地址和凭证
+            $authInfo['UploadAddress'] = $result->UploadAddress;
+            $authInfo['VideoId'] = $result->VideoId;
+            $authInfo['RequestId'] = $result->RequestId;
+            $authInfo['UploadAuth'] = $result->UploadAuth;
+            return $authInfo;
+        } catch (\Exception $e) {
+            return $this->response->error('获取上传凭证失败' . $e->getMessage(),500);
+        }
+    }
+
+    /**
+     * //根据videoId获取播放地址
+     * @param Request $request
+     * @return array|void
+     */
+    public function getPlayUrlByVideoId(Request $request)
+    {
+        $request = $request->all();
+        $validator = Validator::make($request, [
+            'video_id' => 'required'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(),500);
+        }
+        $videoId = $request['video_id'];
+        $url = $this->aliYunVodService->getPlayUrlByVideoId($videoId);
+        return ['url'=>$url];
+    }
+}

+ 1 - 0
app/Http/Controllers/Post/PostController.php

@@ -164,6 +164,7 @@ class PostController extends Controller
             'is_suggest' => ['required',Rule::in(0, 1)],
             'img' => 'required|url',
             'video' => 'required_if:type,video|string|url',
+            'video_id' => 'required_if:type,video|string',
             'topic_ids' => 'required|string|max:64',
             'title' => 'nullable|string|max:20',
             'content' => 'required|string',

+ 143 - 39
app/Repositories/Post/PostRepository.php

@@ -9,6 +9,7 @@
 
 namespace App\Repositories\Post;
 
+use App\Models\Behavior;
 use App\Models\CategoryTopic;
 use App\Models\Post;
 use App\Models\PostComment;
@@ -42,6 +43,7 @@ class PostRepository
                                 PostImgs $postImgs,
                                 PostLog $postLog,
                                 RabbitMqUtil $rabbitMqUtil,
+                                Behavior $behavior,
                                 CategoryTopic $categoryTopic,
                                 PostStatistics $postStatistics,
                                 Topic $topic)
@@ -52,6 +54,7 @@ class PostRepository
         $this->postImgs = $postImgs;
         $this->postLog = $postLog;
         $this->rabbitMqUtil = $rabbitMqUtil;
+        $this->behavior = $behavior;
         $this->categoryTopic = $categoryTopic;
         $this->topic = $topic;
         $this->postStatistics = $postStatistics;
@@ -62,15 +65,16 @@ class PostRepository
      */
     public function create($request)
     {
+
         //验证小号
-        //todo 小号
-//        $userInfo = $this->getUserInfo($request['uid']);
-//        if(!$userInfo || $userInfo['type'] != 1){
-//            return Response::create([
-//                'message'  => '所选小号信息有误',
-//                'status_code'   => 500
-//            ]);
-//        }
+        $userInfo = $this->getUserInfo($request['uid']);
+        Log::debug('发布内容小号信息:'.json_encode($userInfo));
+        if(!$userInfo || $userInfo['type'] != 1){
+            return Response::create([
+                'message'  => '所选小号信息有误',
+                'status_code'   => 500
+            ]);
+        }
         //验证话题
         $topicIdsArray = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();
         $topicCount = count($topicIdsArray);
@@ -92,13 +96,14 @@ class PostRepository
         }
 
         $data = [
-            'uid' => $request['uid'],
-            'username' => '暂无',
-            'mobile' => '13720758488',
-            'avatar' => 'https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83ep3asJn8emiat1MnPdviaPNroWY3f65y5ezkTAk2qtibv7ea9Ht9R2ahxr9bicY1DIj5vN5FibpDOwXegg/132',
+            'uid' => $userInfo['uid'],
+            'username' => $userInfo['username'],
+            'mobile' => $userInfo['mobile'],
+            'avatar' => $userInfo['avatar']??'',
             'type' => $request['type'],
             'img' => $request['img'],
             'video' => $request['video'] ?? '',
+            'video_id' => $request['video_id'] ?? '',
             'topic_ids' => $topicIds,
             'title' => $request['title'] ?? '',
             'content' => $request['content'],
@@ -150,6 +155,25 @@ class PostRepository
             foreach ($topicIdsArray as $id) {
                 Redis::zincrby('topic.user_uid' . $request['uid'], 1, $id);
             }
+
+            $virus = $this->behavior->where('behavior_identification', 'publish')->first();
+            if($virus){
+                if($post->title){
+                    $desc = $post->title;
+                }else{
+                    $desc = subtext(strip_tags($post->content), 20);
+                }
+                $this->rabbitMqUtil->push('virus_add', [
+                    'behavior_id' => $virus->virus_behavior_id,
+                    'behavior_flag' => 'publish',
+                    'post_id' => $post->id,
+                    'post_desc' => $desc,
+                    'post_cover' => $post->img,
+                    'target_id' => $post->uid,
+                    'action_id' => $post->id,
+                ]);
+            }
+
             return Response::create();
 
         } catch (QueryException $exception) {
@@ -178,9 +202,23 @@ class PostRepository
         $uid = $token['user']->id;
         $username = $token['user']->username;
         //验证小号数量
-
+        $number = max([
+            $request['add_pv'],
+            $request['add_praise_count'],
+            $request['add_collect_count'],
+            $request['add_share_count']
+        ]);
+
+        $members = $this->getSystemMember($number);
+        if(!$members || $members['status_code'] != 200){
+            return Response::create([
+                'message' => $members['message'],
+                'status_code' => 500
+            ]);
+        }
+        $post = $this->post->find($request['post_id']);
         $postData = $this->postData->where('post_id', $request['post_id'])->first();
-        if (!$postData) {
+        if (!$postData || !$post) {
             return Response::create([
                 'message' => '获取内容失败',
                 'status_code' => 500
@@ -227,6 +265,62 @@ class PostRepository
             ]);
 
             DB::commit();
+
+            $virus = $this->behavior
+                ->whereIn('behavior_identification', ['read', 'forward', 'like', 'collect'])
+                ->pluck('virus_behavior_id', 'behavior_identification');
+            if($post->title){
+                $desc = $post->title;
+            }else{
+                $desc = subtext(strip_tags($post->content), 20);
+            }
+            $data = [
+                'behavior_value' => 1,
+                'post_id' => $post->id,
+                'post_author_uid' => $post->uid,
+                'post_desc' => $desc,
+                'post_cover' => $post->img,
+                'action_id' => $post->id,
+            ];
+
+            foreach($members['data'] as $key => $member){
+                if(isset($virus['read']) && $request['add_pv'] > $key){
+                    $newData = array_merge($data, [
+                        'behavior_id' => $virus['read'],
+                        'behavior_flag' => 'read',
+                        'target_id' => $member['uid'],
+                    ]);
+                    $this->rabbitMqUtil->push('virus_add', $newData);
+                }
+
+                if(isset($virus['like']) && $request['add_praise_count'] > $key){
+                    $newData = array_merge($data, [
+                        'behavior_id' => $virus['like'],
+                        'behavior_flag' => 'like',
+                        'target_id' => $member['uid'],
+                    ]);
+                    $this->rabbitMqUtil->push('virus_add', $newData);
+                }
+
+                if(isset($virus['collect']) && $request['add_collect_count'] > $key){
+                    $newData = array_merge($data, [
+                        'behavior_id' => $virus['collect'],
+                        'behavior_flag' => 'collect',
+                        'target_id' => $member['uid'],
+                    ]);
+                    $this->rabbitMqUtil->push('virus_add', $newData);
+                }
+
+                if(isset($virus['forward']) && $request['add_share_count'] > $key){
+                    $newData = array_merge($data, [
+                        'behavior_id' => $virus['forward'],
+                        'behavior_flag' => 'forward',
+                        'target_id' => $member['uid'],
+                    ]);
+                    $this->rabbitMqUtil->push('virus_add', $newData);
+                }
+            }
+
             return Response::create();
 
         } catch (QueryException $exception) {
@@ -269,10 +363,13 @@ class PostRepository
             'username' => $userInfo['username'],
             'reply_uid' => 0,
             'reply_username' => '',
-            'avatar' => $userInfo['avatar'],
+            'avatar' => $userInfo['avatar']??'',
             'content' => $request['content'],
             'is_delete' => 0,
         ];
+        $parentCommentContent = '';
+        $parentCommentUid = 0;
+        $parentCommentTime = '';
         if (isset($request['parent_id']) && $request['parent_id'] != 0) {
             $comment = $this->postComment->find($request['parent_id']);
             if (!$comment) {
@@ -290,37 +387,44 @@ class PostRepository
             $data['parent_id'] = $request['parent_id'];
             $data['reply_uid'] = $comment->uid;
             $data['reply_username'] = $comment->username;
-            $this->rabbitMqUtil->push('add_message', [
-                'uid' => $comment->uid,
-                'message_show_type' => 'post_reply_main',
-                'param' => [
-                    'uid' => $userInfo['uid'],
-                    'username' => $userInfo['username'],
-                    'post_id' => $post->id,
-                    'cover' => $post->img,
-                    'content' => subtext($request['content'], 20),
-                ]
-            ]);
-        } else {
-            $this->rabbitMqUtil->push('add_message', [
-                'uid' => $post->uid,
-                'message_show_type' => 'post_comment',
-                'param' => [
-                    'uid' => $userInfo['uid'],
-                    'username' => $userInfo['username'],
-                    'post_id' => $post->id,
-                    'cover' => $post->img,
-                    'content' => subtext($request['content'], 20),
-                ]
-            ]);
+            $parentCommentContent = $comment->content;
+            $parentCommentUid = $comment->uid;
+            $parentCommentTime = Carbon::parse($comment->created_at)->toDateTimeString();
         }
         DB::beginTransaction();
         try {
-            $this->postComment->create($data);
+            $comment = $this->postComment->create($data);
             $post->data->comment_count += 1;
             $post->data->save();
 
             DB::commit();
+
+            $virus = $this->behavior->where('behavior_identification', 'comment')->first();
+            if($virus){
+                if($post->title){
+                    $desc = $post->title;
+                }else{
+                    $desc = subtext(strip_tags($post->content), 20);
+                }
+                $this->rabbitMqUtil->push('virus_add', [
+                    'behavior_id' => $virus->virus_behavior_id,
+                    'behavior_flag' => 'comment',
+                    'post_id' => $post->id,
+                    'post_author_uid' => $post->uid,
+                    'post_desc' => $desc,
+                    'post_cover' => $post->img,
+                    'comment_id' => $comment->id,
+                    'comment_content' => $comment->content,
+                    'parent_comment_id' => $comment->parent_id,
+                    'parent_comment_content' => $parentCommentContent,
+                    'parent_comment_uid' => $parentCommentUid,
+                    'parent_comment_time' => $parentCommentTime,
+                    'reply_uid' => $comment->reply_uid,
+                    'reply_username' => $comment->reply_username,
+                    'target_id' => $comment->uid,
+                    'action_id' => $comment->id,
+                ]);
+            }
             return Response::create();
 
         } catch (QueryException $exception) {

+ 44 - 0
app/Service/AliYunVodService.php

@@ -0,0 +1,44 @@
+<?php
+namespace App\Service;
+
+
+use Illuminate\Support\Facades\Log;
+use ShaoZeMing\AliVod\SDK\GetPlayInfoRequest;
+use ShaoZeMing\Aliyun\Core\DefaultAcsClient;
+use ShaoZeMing\Aliyun\Core\Profile\DefaultProfile;
+
+class AliYunVodService
+{
+    public function getPlayUrlByVideoId($videoId)
+    {
+        try {
+            $client = $this->initVodClient(config('aliyunvod.vod.AccessKeyID'), config('aliyunvod.vod.AccessKeySecret'));
+            $playInfo = $this->getPlayInfo($client, $videoId);
+            if($playInfo && is_object($playInfo)){
+                return $playInfo->PlayInfoList->PlayInfo[0]->PlayURL;
+            }else{
+                return '';
+            }
+        } catch (\Exception $e) {
+            Log::debug('获取视频地址失败:' . $e->getMessage());
+            return '';
+        }
+    }
+
+    private function initVodClient($accessKeyId, $accessKeySecret)
+    {
+        $regionId = 'cn-shanghai';  // 点播服务接入区域
+        $profile = DefaultProfile::getProfile($regionId, $accessKeyId, $accessKeySecret);
+        return new DefaultAcsClient($profile);
+    }
+
+    private function getPlayInfo($client, $videoId)
+    {
+        $request = new GetPlayInfoRequest();
+        $request->setVideoId($videoId);
+        $request->setAcceptFormat('JSON');
+        $playConfig = ['PlayDomain' => 'http://oss.caihongxingqiu.net/'];
+        $request->setPlayConfig(json_encode($playConfig));
+        return $client->getAcsResponse($request);
+    }
+}

+ 13 - 0
app/Traits/UserTrait.php

@@ -23,4 +23,17 @@ trait UserTrait
         }
 
     }
+
+    public function getSystemMember($number) {
+        try {
+            $url = config("customer.manage_service_url").'/user/member/getSystemMember';
+            $array = [
+                'json' => ['number' => $number], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
+            ];
+            return http($url,$array, false, 'get');
+        } catch (\Exception $e) {
+            return [];
+        }
+
+    }
 }

+ 1 - 0
bootstrap/app.php

@@ -31,6 +31,7 @@ $app->configure('jwt');
 $app->configure('customer');
 $app->configure('database');
 $app->configure('constants');
+$app->configure('aliyunvod');
 
 /*
 |--------------------------------------------------------------------------

+ 1 - 0
composer.json

@@ -18,6 +18,7 @@
         "php-amqplib/php-amqplib": "^2.9",
         "predis/predis": "^1.1",
         "tymon/jwt-auth": "1.0.0-rc.4.1",
+        "shaozeming/aliyun-vod": "^2.0",
         "vlucas/phpdotenv": "^3.3"
     },
     "require-dev": {

+ 20 - 0
config/aliyunvod.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: shaozeming
+ * Date: 2019/3/9
+ * Time: 11:57 AM
+ */
+
+return [
+
+    /*点播配置*/
+    'vod' => [
+        'AccessKeyID' => 'LTAINdryz1AB0KpO',
+        'AccessKeySecret' => 'xjKm6yWIewMBQdJYC3H8CnuIOvBv8l',
+        'regionId' => 'cn-shanghai',   // 点播服务接入区域
+        'timeout' => '3600',  // 如果是获取签名有效时间为多少
+        'type' => 'access',  //类型:access|sts 如果是sts 实例化对象时候需要传入$securityToken
+        'acceptFormat' => 'JSON',  //返回数据格式
+    ],
+];

+ 3 - 0
config/customer.tpl

@@ -3,4 +3,7 @@
 return [
     'jwt_secret' => '{jwt_secret}',
     'manage_service_url' => '{manage_service_url}',
+    'VIRUS_URL' => '{VIRUS_URL}',
+    'VIRUS_APP_ID' => '{VIRUS_APP_ID}',
+    'VIRUS_APP_SECRET' => '{VIRUS_APP_SECRET}',
 ];

+ 35 - 0
database/migrations/2019_06_26_091019_add_video_id_to_table_post.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddVideoIdToTablePost extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('post', function (Blueprint $table) {
+            $table->string('video_id', 32)
+                ->default('')
+                ->after('video')
+                ->comment('视频id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('post', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 1 - 0
resources/lang/zh-CN/validation.php

@@ -106,6 +106,7 @@ return [
         'is_suggest' => '是否推荐',
         'img' => '图片',
         'video' => '视频',
+        'video_id' => '视频id',
         'topic_ids' => '话题id',
         'title' => '标题',
         'content' => '内容',

+ 6 - 0
routes/api.php

@@ -17,6 +17,7 @@ $api->version('v1', [
     'namespace' => 'App\Http\Controllers',
 ], function ($api) {
 
+
     $api->group(['middleware' => 'jwt.chxq_auth'], function ($api) {
         //配置
         $api->get('config', 'ConfigController@index');
@@ -28,6 +29,11 @@ $api->version('v1', [
         //测试用户统计
         $api->get('memberStatistics', 'MemberStatisticsController@index');
 
+        //获取上传凭证和地址
+        $api->get('getVodUploadAuth', 'AliYunVodController@getVodUploadAuth');
+        //根据videoId获取播放地址
+        $api->get('getPlayUrlByVideoId', 'AliYunVodController@getPlayUrlByVideoId');
+
         $api->group(['namespace' => 'Post'], function ($api) {
             $api->get('statistics', 'PostController@statistics');
             //发布内容