|
@@ -0,0 +1,86 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+ * Created by PhpStorm.
|
|
|
+ * User: Administrator
|
|
|
+ * Date: 2019/8/13
|
|
|
+ * Time: 10:59
|
|
|
+ */
|
|
|
+namespace App\Console\Commands;
|
|
|
+
|
|
|
+
|
|
|
+use App\Models\Post;
|
|
|
+use Illuminate\Console\Command;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
+use Illuminate\Support\Facades\Redis;
|
|
|
+
|
|
|
+class UpdatePostInfo extends Command
|
|
|
+{
|
|
|
+
|
|
|
+ * The name and signature of the console command.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $signature = 'post:update_info';
|
|
|
+
|
|
|
+
|
|
|
+ * The console command description.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $description = '更新内容信息';
|
|
|
+
|
|
|
+
|
|
|
+ * Create a new command instance.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __construct(Post $post)
|
|
|
+ {
|
|
|
+ parent::__construct();
|
|
|
+ $this->post = $post;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * Execute the console command.
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ $this->line("开始更新内容信息");
|
|
|
+
|
|
|
+ $this->post->chunk(100, function($posts){
|
|
|
+ foreach($posts as $post){
|
|
|
+ if(!$post->data) continue;
|
|
|
+
|
|
|
+ Redis::HSET('post_info_'.$post->id,
|
|
|
+ 'id', $post->id,
|
|
|
+ 'uid', $post->uid,
|
|
|
+ 'type', $post->type,
|
|
|
+ 'img', $post->img,
|
|
|
+ 'imgs', json_encode(array_column($post->imgs->toArray(), 'img')),
|
|
|
+ 'video', $post->video,
|
|
|
+ 'topic_ids', $post->topic_ids,
|
|
|
+ 'title', $post->title,
|
|
|
+ 'content', $post->content,
|
|
|
+ 'location', $post->location,
|
|
|
+ 'pv', $post->data->pv,
|
|
|
+ 'dislike_count', $post->data->dislike_count,
|
|
|
+ 'praise_count', $post->data->praise_count,
|
|
|
+ 'share_count', $post->data->share_count,
|
|
|
+ 'comment_count', $post->data->comment_count,
|
|
|
+ 'collect_count', $post->data->collect_count,
|
|
|
+ 'available_bean', $post->data->available_bean,
|
|
|
+ 'will_collect_bean', $post->data->will_collect_bean,
|
|
|
+ 'create_bean', $post->data->create_bean,
|
|
|
+ 'collect_bean', $post->data->collect_bean,
|
|
|
+ 'weight', $post->data->weight);
|
|
|
+ }
|
|
|
+ usleep(100000);
|
|
|
+ });
|
|
|
+ $this->line("更新内容信息结束");
|
|
|
+
|
|
|
+ }
|
|
|
+}
|