|
|
@@ -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??[]);
|
|
|
+ }
|
|
|
}
|