소스 검색

内容地址

wzq 5 년 전
부모
커밋
c7607cb022

+ 4 - 4
app/Http/Controllers/V1/PostController.php

@@ -90,7 +90,7 @@ class PostController extends Controller
         }
         $list = $this->postRepositories->lists($request->all());
         $fractal = new Manager();
-        $resource = new Collection($list, new ListTransformer($userInfo['uid']));
+        $resource = new Collection($list, new ListTransformer($userInfo['uid'], $userInfo['invite_code']));
         $resource->setPaginator(new IlluminatePaginatorAdapter($list));
         $data = $fractal->createData($resource)->toArray();
 
@@ -108,7 +108,7 @@ class PostController extends Controller
         }
         $list = $this->postRepositories->video($request->all());
         $fractal = new Manager();
-        $resource = new Collection($list, new VideoTransformer($userInfo['uid']));
+        $resource = new Collection($list, new VideoTransformer($userInfo['uid'], $userInfo['invite_code']));
         $resource->setPaginator(new IlluminatePaginatorAdapter($list));
         $data = $fractal->createData($resource)->toArray();
 
@@ -160,7 +160,7 @@ class PostController extends Controller
         $param = $request->all();
         $list = $this->postRepositories->suggestPost($param);
         $fractal = new Manager();
-        $resource = new Collection($list, new SuggestTransformer($userInfo['uid']));
+        $resource = new Collection($list, new SuggestTransformer($userInfo['uid'], $userInfo['invite_code']));
         $resource->setPaginator(new IlluminatePaginatorAdapter($list));
         $data = $fractal->createData($resource)->toArray();
 
@@ -342,7 +342,7 @@ class PostController extends Controller
         }
         $list = $this->postRepositories->topicPost($request->all());
         $fractal = new Manager();
-        $resource = new Collection($list, new TopicPostTransformer($userInfo['uid']));
+        $resource = new Collection($list, new TopicPostTransformer($userInfo['uid'], $userInfo['invite_code']));
         $resource->setPaginator(new IlluminatePaginatorAdapter($list));
         $data = $fractal->createData($resource)->toArray();
 

+ 10 - 6
app/Repositories/FeedRepositories.php

@@ -109,9 +109,12 @@ class FeedRepositories
     }
     //我的feed
     public function myFeed($request){
-        $token =  JWTAuth::decode(JWTAuth::getToken());
+        $userInfo = $this->getUserInfo();
+        if (empty($userInfo)) {
+            return jsonError('获取用户信息失败');
+        }
         $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
-        $where[] = ['uid',$token['user']->uid];
+        $where[] = ['uid',$userInfo['uid']];
         $data = $this->feed
             ->where($where)
             ->orderBy('id','desc')
@@ -120,7 +123,7 @@ class FeedRepositories
             foreach ($data as &$value){
                 if($value['type'] == 6){
                     $post = $this->postRepositories->detail($value['relate_id']);
-                    $value['relate_data'] = $this->postDetail($post,$value['follow_uid']);
+                    $value['relate_data'] = $this->postDetail($post,$value['follow_uid'], $userInfo);
                 }
                 if($value['type'] == 5){
                     $value['content'] = null;
@@ -134,9 +137,8 @@ class FeedRepositories
         }
         return $data;
     }
-    public function postDetail($post,$follow_uid){
-        $token =  JWTAuth::decode(JWTAuth::getToken());
-        $uid = $token['user']->uid;
+    public function postDetail($post,$follow_uid,$userInfo){
+        $uid = $userInfo['uid'];
         $imgs = [];
         foreach($post->imgs as $img){
             $imgs[] = $img['img'];
@@ -178,6 +180,8 @@ class FeedRepositories
             'is_dislike' => PostDislike::where('post_id', $post['id'])->where('uid', $uid)->exists()?1:0,
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $uid)->exists()?1:0,
             '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']:'',
         ];
     }
     public function getPostComment($post_id){

+ 1 - 1
app/Repositories/PostRepositories.php

@@ -543,7 +543,7 @@ class PostRepositories
                 'id' => $topic->id,
                 'name' => $topic->name,
                 'img' => $topic->img,
-                'follow_count' => (string) getNumber($topic->follow->count() + config('customer.add_topic_follow_count')),
+                'follow_count' => getNumber($topic->follow->count() + config('customer.add_topic_follow_count')),
             ];
         }
         return $data;

+ 4 - 1
app/Transformers/Post/ListTransformer.php

@@ -13,9 +13,10 @@ use League\Fractal\TransformerAbstract;
 
 class ListTransformer extends TransformerAbstract
 {
-    public function __construct($uid)
+    public function __construct($uid, $invite_code)
     {
         $this->uid = $uid;
+        $this->invite_code = $invite_code;
     }
     public function transform(Post $post)
     {
@@ -29,6 +30,8 @@ class ListTransformer extends TransformerAbstract
             'img' => $post['img'],
             'praise_count' => $post->data->praise_count,
             'is_like' => PostLike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
+            'h5url' => config('customer.share_post_h5url')."?post_id={$post['id']}&invite_code={$this->invite_code}",
+            'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'',
         ];
     }
 }

+ 3 - 1
app/Transformers/Post/SuggestTransformer.php

@@ -20,9 +20,10 @@ use League\Fractal\TransformerAbstract;
 class SuggestTransformer extends TransformerAbstract
 {
     use UserTrait;
-    public function __construct($uid)
+    public function __construct($uid, $invite_code)
     {
         $this->uid = $uid;
+        $this->invite_code = $invite_code;
     }
     public function transform(Post $post)
     {
@@ -88,6 +89,7 @@ class SuggestTransformer extends TransformerAbstract
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'comment' => $comment,
             'is_follow' => $isFollow,
+            'h5url' => config('customer.share_post_h5url')."?post_id={$post['id']}&invite_code={$this->invite_code}",
             'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'',
         ];
     }

+ 4 - 1
app/Transformers/Post/VideoTransformer.php

@@ -16,9 +16,10 @@ use League\Fractal\TransformerAbstract;
 class VideoTransformer extends TransformerAbstract
 {
     use UserTrait;
-    public function __construct($uid)
+    public function __construct($uid, $invite_code)
     {
         $this->uid = $uid;
+        $this->invite_code = $invite_code;
     }
     public function transform(Post $post)
     {
@@ -51,6 +52,8 @@ class VideoTransformer extends TransformerAbstract
             'is_like' => PostLike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_follow' => $isFollow,
+            'h5url' => config('customer.share_post_h5url')."?post_id={$post['id']}&invite_code={$this->invite_code}",
+            'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'',
         ];
     }
 }

+ 1 - 1
app/Transformers/Topic/TopicDetailTransformer.php

@@ -23,7 +23,7 @@ class TopicDetailTransformer extends TransformerAbstract
             'id' => $topic['id'],
             'name' => subtext($topic['name'], 5),
             'img' => $topic['img'],
-            'follow_count' => (string) getNumber($topic->follow->count() + config('customer.add_topic_follow_count')),
+            'follow_count' => getNumber($topic->follow->count() + config('customer.add_topic_follow_count')),
             'is_follow' => $topic->follow->where('uid', $this->uid)->count()?1:0,
         ];
     }

+ 1 - 1
app/Transformers/Topic/TopicListTransformer.php

@@ -19,7 +19,7 @@ class TopicListTransformer extends TransformerAbstract
             'id' => $topic['id'],
             'name' => subtext($topic['name'], 5),
             'img' => $topic['img'],
-            'follow_count' => (string) getNumber($topic->follow->count() + config('customer.add_topic_follow_count')),
+            'follow_count' => getNumber($topic->follow->count() + config('customer.add_topic_follow_count')),
         ];
     }
 }

+ 4 - 1
app/Transformers/Topic/TopicPostTransformer.php

@@ -19,9 +19,10 @@ use League\Fractal\TransformerAbstract;
 class TopicPostTransformer extends TransformerAbstract
 {
     use UserTrait;
-    public function __construct($uid)
+    public function __construct($uid, $invite_code)
     {
         $this->uid = $uid;
+        $this->invite_code = $invite_code;
     }
     public function transform(Post $post)
     {
@@ -85,6 +86,8 @@ class TopicPostTransformer extends TransformerAbstract
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'comment' => $comment,
             'is_follow' => $isFollow,
+            'h5url' => config('customer.share_post_h5url')."?post_id={$post['id']}&invite_code={$this->invite_code}",
+            'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'',
         ];
     }
 }