소스 검색

用户信息

wzq 5 년 전
부모
커밋
6d96ab1938
2개의 변경된 파일9개의 추가작업 그리고 9개의 파일을 삭제
  1. 8 8
      app/Repositories/Post/PostRepository.php
  2. 1 1
      app/Traits/UserTrait.php

+ 8 - 8
app/Repositories/Post/PostRepository.php

@@ -69,7 +69,7 @@ class PostRepository
         //验证小号
         $userInfo = $this->getUserInfo($request['uid']);
         Log::debug('发布内容小号信息:'.json_encode($userInfo));
-        if(!$userInfo || !$userInfo['data'] || $userInfo['data']['type'] != 1){
+        if(!$userInfo || $userInfo['type'] != 1){
             return Response::create([
                 'message'  => '所选小号信息有误',
                 'status_code'   => 500
@@ -96,10 +96,10 @@ class PostRepository
         }
 
         $data = [
-            'uid' => $request['uid'],
-            'username' => '暂无',
-            'mobile' => '13720758488',
-            'avatar' => 'https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83ep3asJn8emiat1MnPdviaPNroWY3f65y5ezkTAk2qtibv7ea9Ht9R2ahxr9bicY1DIj5vN5FibpDOwXegg/132',
+            'uid' => $userInfo['uid'],
+            'username' => $userInfo['username'],
+            'mobile' => $userInfo['mobile'],
+            'avatar' => $userInfo['avatar']??'',
             'type' => $request['type'],
             'img' => $request['img'],
             'video' => $request['video'] ?? '',
@@ -341,7 +341,7 @@ class PostRepository
         //验证小号
         $userInfo = $this->getUserInfo($request['uid']);
         Log::debug('评论&回复小号' . json_encode($userInfo));
-        if (!$userInfo || !$userInfo['data'] || $userInfo['data']['type'] != 1) {
+        if (!$userInfo || $userInfo['type'] != 1) {
             return Response::create([
                 'message' => '所选小号信息有误',
                 'status_code' => 500
@@ -359,10 +359,10 @@ class PostRepository
             'uid' => $request['uid'],
             'post_id' => $request['post_id'],
             'parent_id' => 0,
-            'username' => $userInfo['data']['username'],
+            'username' => $userInfo['username'],
             'reply_uid' => 0,
             'reply_username' => '',
-            'avatar' => $userInfo['data']['avatar'],
+            'avatar' => $userInfo['avatar']??'',
             'content' => $request['content'],
             'is_delete' => 0,
         ];

+ 1 - 1
app/Traits/UserTrait.php

@@ -17,7 +17,7 @@ trait UserTrait
             $array = [
                 'json' => ['uid' => $uid], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
             ];
-            return http($url,$array, false, 'get');
+            return http($url,$array, true, 'get');
         } catch (\Exception $e) {
             return [];
         }