rkljw 5 mesi fa
parent
commit
497f3487a6
3 ha cambiato i file con 73 aggiunte e 9 eliminazioni
  1. 19 9
      app/JsonRpc/ChatService.php
  2. 27 0
      app/Model/ImGroup.php
  3. 27 0
      app/Model/ImGroupMember.php

+ 19 - 9
app/JsonRpc/ChatService.php

@@ -10,6 +10,8 @@ use App\Model\ChatTopic;
 use App\Model\ChatTopicsReply;
 
 use App\Model\ChatTopicClass;
+use App\Model\ImGroup;
+use App\Model\ImGroupMember;
 use App\Model\User;
 use App\Tools\PublicData;
 use App\Tools\Result;
@@ -776,26 +778,34 @@ class ChatService implements ChatServiceInterface
      */
     public function joinGroup(array $data): array
     {
-        $group = ChatGroups::where(['id' => $data['group_id']])->first();
+        $group = ImGroup::where(['id' => $data['group_id']])->first();
         if (empty($group)) {
             return Result::error("群不存在", 0);
         }
-        $groupMember = ChatGroupsMember::where(['user_id' => $data['user_id'], 'group_id' => $data['group_id']])->first();
+        $groupMember = ImGroupMember::where(['user_id' => $data['user_id'], 'group_id' => $data['group_id']])->first();
         if ($groupMember) {
             return Result::error("已加入群", 0);
         }
-        $info = [
-            'id' => PublicData::uuid(),
-            'user_id' => $data['user_id'],
-            'group_id' => $data['group_id'],
+//        $info = [
+//            'id' => PublicData::uuid(),
+//            'user_id' => $data['user_id'],
+//            'group_id' => $data['group_id'],
+//        ];
+//        $result = ChatGroupsMember::insert($info);
+        $url = env('IM_URL').'/api/v1/group/invite';
+        $dataIM = [
+            'group_id' => intval($data['group_id']),
+            'ids' => _string($data['user_id']),
+        ];
+        $options = [
+            'authorization'=>$data['token']
         ];
-        $result = ChatGroupsMember::insert($info);
-        var_dump($result, '--------------------');
+        $result = PublicData::im_post($url,$dataIM,$options);
         if ($result) {
             return Result::success($data);
         } else {
             return Result::error($data);
-        };
+        }
     }
     /**
      * 话题 - 列表

+ 27 - 0
app/Model/ImGroup.php

@@ -0,0 +1,27 @@
+<?php
+
+declare (strict_types = 1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ImGroup extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'im_group';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 27 - 0
app/Model/ImGroupMember.php

@@ -0,0 +1,27 @@
+<?php
+
+declare (strict_types = 1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ImGroupMember extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'im_group_member';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}