wzq vor 5 Jahren
Ursprung
Commit
f5d00f8e31

+ 20 - 22
app/Repositories/FeedRepositories.php

@@ -157,7 +157,7 @@ class FeedRepositories
         if ($data) {
             foreach ($data as $key => &$value) {
                 if ($value['type'] == 6) {
-                    $post = $this->postRepositories->detail($value['relate_id']);
+                    $post = $this->getPostInfo($value['relate_id'], 1);
                     if ($post) {
                         $value['relate_data'] = $this->postDetail($post, $value['follow_uid'], $userInfo);
                     } else {
@@ -184,45 +184,43 @@ class FeedRepositories
         return $data;
     }
 
-    public function postDetail($post, $follow_uid, $userInfo)
+    public function postDetail($postInfo, $follow_uid, $userInfo)
     {
-        Log::debug('feed流内容--' . json_encode($post));
+        Log::debug('feed流内容--' . json_encode($postInfo));
         $uid = $userInfo['uid'];
-        $postInfo = $this->getPostInfo($post['id']);
-
         $isFollow = 0;
         Log::debug("内容feed关注uid{$uid}followUid{$follow_uid}");
         $followStatus = $this->getFollowStatus($uid, $follow_uid);
         if ($followStatus) {
             $isFollow = $followStatus;
         }
-        $user = $this->userInfo($post['uid']);
+        $user = $this->userInfo($postInfo['uid']);
         return [
-            'id' => $post['id'],
-            'type' => $post['type'],
-            'created_at' => Carbon::parse($post['created_at'])->diffForHumans(),
-            'uid' => $post['uid'],
+            'id' => (int) $postInfo['id'],
+            'type' => $postInfo['type'],
+            'created_at' => Carbon::parse($postInfo['created_at'])->diffForHumans(),
+            'uid' => (int) $postInfo['uid'],
             'username' => $user['username'],
             'avatar' => $user['avatar'],
-            'topic' => $this->getTopic($post['topic_ids']),
-            'title' => $post['title'],
-            'content' => $post['content'],
-            'location' => $post['location'],
-            'img' => $post['img'],
+            'topic' => $this->getTopic($postInfo['topic_ids']),
+            'title' => $postInfo['title'],
+            'content' => $postInfo['content'],
+            'location' => $postInfo['location'],
+            'img' => $postInfo['img'],
             'imgs' => $postInfo['imgs'],
-            'video' => $post['video'],
+            'video' => $postInfo['video'],
             'pv' => getNumber($postInfo['pv']),
             'praise_count' => $postInfo['praise_count'],
             'comment_count' => $postInfo['comment_count'],
             'available_bean' => $postInfo['available_bean'],
             'will_collect_bean' => $postInfo['will_collect_bean'],
-            'post_comment' => $this->getNewComment($post['id']),
-            'is_like' => Redis::SISMEMBER('post_like_'.$post['id'], $uid),
-            'is_dislike' => Redis::SISMEMBER('post_unlike_'.$post['id'], $uid),
-            'is_collect' => Redis::SISMEMBER('post_collect_'.$post['id'], $uid),
+            'post_comment' => $this->getNewComment($postInfo['id']),
+            'is_like' => Redis::SISMEMBER('post_like_'.$postInfo['id'], $uid),
+            'is_dislike' => Redis::SISMEMBER('post_unlike_'.$postInfo['id'], $uid),
+            'is_collect' => Redis::SISMEMBER('post_collect_'.$postInfo['id'], $uid),
             'follow_status' => $isFollow,
-            'h5url' => config('customer.share_post_h5url') . "?post_id={$post['id']}&invite_code={$userInfo['invite_code']}",
-            'desc_url' => $post['type'] == 'html' ? config('customer.app_service_url') . '/community/fragment/detail/' . $post['id'] : '',
+            'h5url' => config('customer.share_post_h5url') . "?post_id={$postInfo['id']}&invite_code={$userInfo['invite_code']}",
+            'desc_url' => $postInfo['type'] == 'html' ? config('customer.app_service_url') . '/community/fragment/detail/' . $postInfo['id'] : '',
         ];
     }
 

+ 2 - 1
app/Repositories/PostRepositories.php

@@ -217,7 +217,8 @@ class PostRepositories
                 'available_bean', $postData->available_bean,
                 'will_collect_bean', $postData->will_collect_bean,
                 'create_bean', $postData->create_bean,
-                'collect_bean', $postData->collect_bean);
+                'collect_bean', $postData->collect_bean,
+                'created_at', $post->created_at);
 
             return jsonSuccess([
                 'post_id' => $post->id,

+ 7 - 1
app/Traits/PostTrait.php

@@ -59,8 +59,14 @@ trait PostTrait
     }
 
     //获取内容详情
-    public function getPostInfo($id)
+    public function getPostInfo($id, $type = 0)
     {
+        if($type){
+            $res = Redis::SISMEMBER('delete_post_ids', $id);
+            if($res){
+                return [];
+            }
+        }
         $data =  Redis::HGETALL('post_info_'.$id);
         if($data){
             $data['praise_count'] = intval($data['praise_count']);