Browse Source

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/user_producer

LiuJ 4 months ago
parent
commit
172640fa35

+ 51 - 4
app/JsonRpc/UserService.php

@@ -2,6 +2,7 @@
 
 namespace App\JsonRpc;
 
+use App\Model\ImContact;
 use App\Model\Role;
 use App\Model\RoleLog;
 use App\Model\RoleUser;
@@ -15,7 +16,7 @@ use App\Tools\Result;
 use Hamcrest\Arrays\IsArray;
 use Hyperf\DbConnection\Db;
 use Hyperf\RpcServer\Annotation\RpcService;
-
+use App\Model\ImGroupMember;
 #[RpcService(name: "UserService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class UserService implements UserServiceInterface
 {
@@ -455,7 +456,7 @@ class UserService implements UserServiceInterface
      */
     public function updateUserInfo(array $data): array
     {
-        return 1;
+        return [];
     }
 
     /**
@@ -486,8 +487,8 @@ class UserService implements UserServiceInterface
     {
         Db::beginTransaction();
         try {
-            User::where(['id' => $id])->delete();
-            UserInfo::where(['user_id' => $id])->delete();
+//            User::where(['id' => $id])->delete();
+//            UserInfo::where(['user_id' => $id])->delete();
             Db::commit();
         } catch (\Throwable $ex) {
             Db::rollBack();
@@ -527,6 +528,11 @@ class UserService implements UserServiceInterface
     {
         Db::beginTransaction();
         try {
+            $count = RoleUser::where(['role_id' => $data['id']])->count();
+            if($count>0){
+                Db::rollBack();
+                return Result::error("请先删除该角色下的用户", 0);
+            }
             $roleInfo = Role::where(['id' => $data['id']])->first();
             $logData = [
                 'user_id' => $data['user_id'],
@@ -750,4 +756,45 @@ class UserService implements UserServiceInterface
             return Result::error('查询失败');
         }
     }
+    /**
+     * 根据类型获取用户列表
+     */
+    public function getTypeUserList(array $data): array
+    {
+        $result = User::when($data, function ($query) use ($data) {
+            if (isset($data['type_id']) && $data['type_id']) {
+                $query->where('type_id', $data['type_id']);
+            }
+        })->where('status', 1)->get();
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error('查询失败');
+        }
+    }
+    /**
+     * 获取群里面的用户,不包含子集
+     */
+    public function getImGroupMember(array $data): array
+    {
+        $result = ImGroupMember::leftjoin("im_group", "im_group.id", "=", "im_group_member.group_id")->when($data, function ($query) use ($data) {
+            if (isset($data['user_id']) && $data['user_id']) {
+                $query->where('im_group_member.user_id', '<>', $data['user_id']);
+            }
+        })
+            ->where('im_group_member.group_id', $data['group_id'])
+            ->select("im_group_member.*", "im_group.group_name")
+            ->get();
+        return Result::success($result??[]);
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getImContact(array $data): array
+    {
+        $result = ImContact::where($data)->first();
+        return Result::success($result??[]);
+    }
 }

+ 18 - 0
app/JsonRpc/UserServiceInterface.php

@@ -125,5 +125,23 @@ interface UserServiceInterface
      * @return array
      */
     public function getWebsiteGroupInfo(array $data): array;
+    /**
+     * 根据类型获取用户列表
+     * @param array $data
+     * @return array
+     */
+    public function getTypeUserList(array $data): array;
+    /**
+     * 获取用户信息
+     * @param array $data
+     * @return array
+     */
+    public function getImGroupMember(array $data): array;
+    /**
+     * 获取用户备注信息
+     * @param array $data
+     * @return array
+     */
+    public function getImContact(array $data): array;
 
 }

+ 28 - 0
app/Model/ImContact.php

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

+ 28 - 0
app/Model/ImGroupMember.php

@@ -0,0 +1,28 @@
+<?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 = [];
+
+   
+}