wzq 5 anni fa
parent
commit
aef4163b6e
1 ha cambiato i file con 26 aggiunte e 1 eliminazioni
  1. 26 1
      app/Repositories/Post/PostRepository.php

+ 26 - 1
app/Repositories/Post/PostRepository.php

@@ -129,7 +129,7 @@ class PostRepository
         try {
             $post = $this->post->create($data);
 
-            $this->postData->create([
+            $postData = $this->postData->create([
                 'post_id' => $post->id,
                 'pv' => 0,
                 'pv_real' => 0,
@@ -147,9 +147,11 @@ class PostRepository
                 'weight' => $score
             ]);
 
+            $imgs = [];
             if (!empty($request['imgs']) && $request['type'] == 'image') {
                 $imgData = [];
                 foreach ($request['imgs'] as $img) {
+                    $imgs[] = $img;
                     $imgData[] = [
                         'post_id' => $post->id,
                         'img' => $img,
@@ -185,6 +187,29 @@ class PostRepository
                 ]);
             }
 
+            Redis::HSET('post_info_'.$post->id,
+                'id', $post->id,
+                'uid', $post->uid,
+                'type', $post->type,
+                'img', $post->img,
+                'imgs', json_encode($imgs),
+                'video', $post->video,
+                'topic_ids', $post->topic_ids,
+                'title', $post->title,
+                'content', $post->content,
+                'location', $post->location,
+                'pv', $postData->pv,
+                'dislike_count', $postData->dislike_count,
+                'praise_count', $postData->praise_count,
+                'share_count', $postData->share_count,
+                'comment_count', $postData->comment_count,
+                'collect_count', $postData->collect_count,
+                'available_bean', $postData->available_bean,
+                'will_collect_bean', $postData->will_collect_bean,
+                'create_bean', $postData->create_bean,
+                'collect_bean', $postData->collect_bean,
+                'weight', $postData->weight);
+
             return Response::create();
 
         } catch (QueryException $exception) {