Selaa lähdekoodia

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

zhangchangchun 5 vuotta sitten
vanhempi
commit
f067368dbb

+ 10 - 6
app/Console/Commands/Downloads.php

@@ -12,6 +12,7 @@ use App\Repositories\Post\PostRepository;
 use Illuminate\Console\Command;
 use App\Models\Download;
 use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\Storage;
 
 class Downloads extends Command
 {
@@ -60,28 +61,31 @@ class Downloads extends Command
         if(!$download) exit;
 
         if($download->download_type == 'post'){
-            $filePath = $fileDir .$download->username.'内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $fileName = '内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }elseif($download->download_type == 'post_waste'){
-            $filePath = $fileDir .$download->username.'回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $fileName = '回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }elseif($download->download_type == 'registered_record'){
-            $filePath = $fileDir .$download->username.'新用户注册账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $fileName = '新用户注册账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }elseif($download->download_type == 'comment_record'){
-            $filePath = $fileDir .$download->username.'评论账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $fileName = '评论账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }elseif($download->download_type == 'release_record'){
-            $filePath = $fileDir .$download->username.'发布账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $fileName = '发布账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }elseif($download->download_type == 'general_record'){
-            $filePath = $fileDir .$download->username.'唯一/普通行为账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+            $fileName = '唯一/普通行为账本-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
         }else{
             exit;
         }
         $download->download_status = 1;
         $download->save();
 
+        $filePath = $fileDir .$download->username.$fileName;
         try {
             $this->postRepository->download($filePath, $download->download_type, json_decode($download->params, true));
+            Storage::put($filePath, file_get_contents(public_path($filePath)));
             $download->url = $filePath;
             $download->download_status = 2;
             $download->save();
+            unlink(public_path($filePath));
         } catch (\Exception $e) {
             $download->download_status = 3;
             $download->url = $e->getMessage();

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

@@ -56,6 +56,7 @@ class PostController extends Controller
                 'created_at',
                 'uid',
                 'topic',
+                'content',
                 'location',
                 'pv',
                 'praise_count',

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

@@ -450,9 +450,6 @@ class PostRepository
     {
         $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
         $where = [];
-        if (isset($request['content'])) {
-            $where[] = ['content', 'like', "%{$request['content']}%"];
-        }
         if (isset($request['is_suggest'])) {
             $where[] = ['is_suggest', $request['is_suggest']];
         }
@@ -484,6 +481,12 @@ class PostRepository
                         ->orWhere('mobile', 'like', "%{$request['keyword']}%");
                 }
             })
+            ->where(function ($query) use ($request) {
+                if (isset($request['content'])) {
+                    $query->where('title', 'like', "%{$request['content']}%")
+                        ->orWhere('content', 'like', "%{$request['content']}%");
+                }
+            })
             ->where(function ($query) use ($request) {
                 if (isset($request['created_at'])) {
                     $time = explode('_', $request['created_at']);
@@ -593,12 +596,35 @@ class PostRepository
                 'status_code' => 500
             ]);
         }
+        $uid = $post->uid;
+        $title = $post->title;
+        if(!$title){
+            $title = subtext(strip_tags($post->content), 20);
+        }
+        $content = "经核实您的内容“{$title}”涉及违规,现已被删除,有任何问题请联系彩虹管理员";
 
+        $date = Carbon::now()->toDateTimeString();
         DB::beginTransaction();
         try {
             $post->delete();
 
             DB::commit();
+            $this->rabbitMqUtil->push('add_message_one', [
+                'uid' => $uid,
+                'message_rule_id' => 0,
+                'message_type' => 1,
+                'message_show_type' => 'post_delete',
+                'param' => [
+                    'title' => '内容删除',
+                    'content' => $content,
+                    'cover' => '',
+                    'activity_url' => 0,
+                    'activity_time' => '',
+                ],
+                'is_read' => 0,
+                'created_at' => $date,
+                'updated_at' => $date,
+            ]);
             return Response::create();
 
         } catch (QueryException $exception) {

+ 1 - 1
app/Transformers/Post/PostTransformer.php

@@ -23,7 +23,7 @@ class PostTransformer extends TransformerAbstract
             'username' => $post['username'],
             'avatar' => $post['avatar'],
             'topic' => $post->topic(),
-            'content' => subtext($post['content'], 20),
+            'content' => subtext(strip_tags($post['content']), 20),
             'location' => $post['location'],
             'pv' => $post->data->pv_real.'/'.$post->data->pv,
             'praise_count' => $post->data->praise_real_count.'/'.$post->data->praise_count,

+ 1 - 0
bootstrap/app.php

@@ -91,6 +91,7 @@ $app->register(App\Providers\AuthServiceProvider::class);
 $app->register(Dingo\Api\Provider\LumenServiceProvider::class);
 $app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
 $app->register(\Illuminate\Redis\RedisServiceProvider::class);
+$app->register(\Junliuxian\AliOSS\AliOssServiceProvider::class);
 /*
 |--------------------------------------------------------------------------
 | Load The Application Routes

+ 1 - 0
composer.json

@@ -21,6 +21,7 @@
         "shaozeming/aliyun-vod": "^2.0",
         "tymon/jwt-auth": "1.0.0-rc.4.1",
         "vlucas/phpdotenv": "^3.3",
+        "junliuxian/ali-oss-storage": "~2.0",
         "wapmorgan/mp3info": "^0.0.4"
     },
     "require-dev": {

+ 82 - 0
config/filesystems.php

@@ -0,0 +1,82 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default Filesystem Disk
+    |--------------------------------------------------------------------------
+    |
+    | Here you may specify the default filesystem disk that should be used
+    | by the framework. The "local" disk, as well as a variety of cloud
+    | based disks are available to your application. Just store away!
+    |
+    */
+
+    'default' => env('FILESYSTEM_DRIVER', 'oss'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Default Cloud Filesystem Disk
+    |--------------------------------------------------------------------------
+    |
+    | Many applications store files both locally and in the cloud. For this
+    | reason, you may specify a default "cloud" driver here. This driver
+    | will be bound as the Cloud disk implementation in the container.
+    |
+    */
+
+    'cloud' => env('FILESYSTEM_CLOUD', 's3'),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Filesystem Disks
+    |--------------------------------------------------------------------------
+    |
+    | Here you may configure as many filesystem "disks" as you wish, and you
+    | may even configure multiple disks of the same driver. Defaults have
+    | been setup for each driver as an example of the required options.
+    |
+    | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
+    |
+    */
+
+    'disks' => [
+
+        'local' => [
+            'driver' => 'local',
+            'root' => storage_path('app'),
+        ],
+
+        'public' => [
+            'driver' => 'local',
+            'root' => storage_path('app/public'),
+            'url' => env('APP_URL') . '/storage',
+            'visibility' => 'public',
+        ],
+
+        's3' => [
+            'driver' => 's3',
+            'key' => env('AWS_ACCESS_KEY_ID'),
+            'secret' => env('AWS_SECRET_ACCESS_KEY'),
+            'region' => env('AWS_DEFAULT_REGION'),
+            'bucket' => env('AWS_BUCKET'),
+            'url' => env('AWS_URL'),
+        ],
+
+        'oss' => [
+            'driver' => 'oss',
+            'access_id' => 'LTAIGTDKUOVQf2Ln',
+            'access_key' => 'HzY9r2gDPbURQ0Vp69A7THV0RmxMkb',
+            'bucket' => 'rainbowstar',
+            'endpoint' => 'oss-cn-zhangjiakou.aliyuncs.com', // OSS 外网节点或自定义外部域名
+//            'endpoint_internal' => '<internal endpoint [OSS内网节点] 如:oss-cn-shenzhen-internal.aliyuncs.com>', // v2.0.4 新增配置属性,如果为空,则默认使用 endpoint 配置(由于内网上传有点小问题未解决,请大家暂时不要使用内网节点上传,正在与阿里技术沟通中)
+            'cdnDomain' => '', // 如果isCName为true, getUrl会判断cdnDomain是否设定来决定返回的url,如果cdnDomain未设置,则使用endpoint来生成url,否则使用cdn
+            'ssl' => false, // true to use 'https://' and false to use 'http://'. default is false,
+            'isCName' => false, // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url, false: 则使用外部节点生成url
+            'debug' => true,
+        ],
+
+    ],
+
+];

+ 1 - 1
database/migrations/2019_06_14_155026_create_table_feed.php

@@ -39,7 +39,7 @@ class CreateTableFeed extends Migration
                 ->default(0)
                 ->comment('相关id');
 
-            $table->string('content', 200)
+            $table->string('content', 1000)
                 ->default('')
                 ->comment('内容');
 

BIN
public/1.png