Browse Source

bug修复

121708259@qq.com 3 năm trước cách đây
mục cha
commit
c897a6723f

+ 1 - 0
app/Http/Controllers/Api/DynamicController.php

xqd
@@ -192,6 +192,7 @@ class DynamicController extends Controller
             $UserReportParam->user_id = $user->id;
             $UserReportParam->content = $request->post('content');
             $UserReportParam->report_id = $request->post('id');
+            $UserReportParam->tencent_im_user_id = $request->post('tencent_im_user_id');
             $UserReportParam->status = 0;
             $UserReportParam->img_url = $request->post('img_url');
             $UserReportParam->info = $request->post('info',"");

+ 1 - 0
app/Http/Controllers/Api/HomeController.php

xqd
@@ -218,6 +218,7 @@ class HomeController extends Controller
     public function lahei(Request $request){
         try {
             $param['user_id'] = $request->user_id;
+            $param['tencent_im_user_id'] = $request->tencent_im_user_id;
             $this->homeService->lahei($param);
         }catch (\Exception $exception){
             return $this->response->errorForbidden($exception->getMessage());

+ 1 - 0
app/Http/Params/UserReportParam.php

xqd
@@ -11,4 +11,5 @@ class UserReportParam
     public $info;
     public $status;
     public $type;
+    public $tencent_im_user_id;
 }

+ 6 - 1
app/Services/DynamicService.php

xqd
@@ -253,7 +253,12 @@ class DynamicService
                 throw new Exception("动态不存在");
             }
         }else{
-            $user = User::query()->where('id',$userReportParam->report_id)->first();
+            if(!empty($userReportParam->id)&& $userReportParam->report_id>0){
+                $user = User::query()->where('id',$userReportParam->report_id)->first();
+            }
+            if(!empty($userReportParam->tencent_im_user_id)){
+                $user = User::query()->where('tencent_im_user_id',$userReportParam->tencent_im_user_id)->first();
+            }
             if(!$user){
                 throw new Exception("用户不存在");
             }

+ 7 - 4
app/Services/HomeService.php

xqd
@@ -283,13 +283,16 @@ class HomeService
     //拉黑用户
     public function lahei($param){
         $user = auth('api')->user();
-        if(empty($param['user_id'])){
-            throw new Exception("参数错误");
+        if(!empty($param['user_id'])&& $param['user_id']>0){
+            $touser = User::query()->where('id',$param['user_id'])->first();
         }
-        if(!$touser = User::query()->where('id',$param['user_id'])->first()){
-            throw new Exception("用户不存在");
+        if(!empty($param['tencent_im_user_id'])){
+            $touser = User::query()->where('tencent_im_user_id',$param['tencent_im_user_id'])->first();
         }
 
+        if(!$touser){
+            throw new Exception("用户不存在");
+        }
         $tencentim = new TencentImFriendService();
 
         $res = $tencentim->friend_black_add($user->tencent_im_user_id,$touser->tencent_im_user_id);