Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Compare Revisions
master...feature/super-country
Source
feature/super-country
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (2)
feat:超管操作
· 0e7f49fb
hujiebin
authored
May 19, 2023
0e7f49fb
超管处理下麦
· 8f1ffffb
hujiebin
authored
May 19, 2023
8f1ffffb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
10 deletions
+46
-10
mic.go
domain/model/group_m/mic.go
+10
-5
superManager.go
domain/model/user_m/superManager.go
+32
-1
group_op.go
domain/service/group_s/group_op.go
+1
-1
group_op.go
route/group_r/group_op.go
+2
-2
group_setting.go
route/group_r/group_setting.go
+1
-1
No files found.
domain/model/group_m/mic.go
View file @
8f1ffffb
...
...
@@ -291,12 +291,17 @@ func (micUser *MicUser) leave(operateUserId uint64, operateExternalId string) er
}
//
externalId
:=
micUser
.
ExternalId
// 超管处理
if
flag
,
err
:=
user_m
.
IsSuperManagerV2
(
micUser
.
model
,
operateUserId
,
micUser
.
UserId
);
err
!=
nil
{
return
err
}
else
if
!
flag
{
if
micUser
.
ExternalId
!=
operateExternalId
{
//检查权限,管理人权限, 不过不拥有管理人权限,则抛出错误
if
err
:=
MgrPermission
(
micUser
.
model
,
micUser
.
GroupUuid
,
operateUserId
,
micUser
.
UserId
);
err
!=
nil
{
return
err
}
}
}
//设置值到redis
//redisCli.GetRedis().ScriptFlush(context.Background())
script
:=
strings
.
Replace
(
strings
.
Replace
(
...
...
@@ -576,7 +581,7 @@ func (micUser *MicUser) SpeechClose(userId uint64, externalId, lang string) erro
}
else
if
flag
{
//不能让超级管理人移除
return
bizerr
.
OfficialStaffLimit
}
else
if
flag
,
err
:=
user_m
.
IsSuperManager
(
micUser
.
model
,
u
serId
);
err
!=
nil
{
}
else
if
flag
,
err
:=
user_m
.
IsSuperManager
V2
(
micUser
.
model
,
userId
,
micUser
.
U
serId
);
err
!=
nil
{
return
err
}
else
if
flag
{
//超级管理人,无敌状态
...
...
domain/model/user_m/superManager.go
View file @
8f1ffffb
...
...
@@ -3,13 +3,17 @@ package user_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/myerr"
"strings"
)
type
SuperManager
struct
{
mysql
.
Entity
*
domain
.
Model
`gorm:"-"`
UserId
mysql
.
ID
IsAll
bool
Countries
string
}
func
IsSuperManager
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
bool
,
error
)
{
...
...
@@ -22,6 +26,33 @@ func IsSuperManager(model *domain.Model, userId mysql.ID) (bool, error) {
return
n
>
0
,
nil
}
// 对某人是否有超管权限
func
IsSuperManagerV2
(
model
*
domain
.
Model
,
userId
,
targetUserId
mysql
.
ID
)
(
bool
,
error
)
{
var
man
SuperManager
if
err
:=
model
.
Db
.
Model
(
&
SuperManager
{})
.
Where
(
&
SuperManager
{
UserId
:
userId
,
})
.
First
(
&
man
)
.
Error
;
err
!=
nil
{
if
err
!=
gorm
.
ErrRecordNotFound
{
model
.
Log
.
Errorf
(
"IsSuperManagerV2 fail:%v"
,
err
)
}
return
false
,
nil
}
if
man
.
IsAll
{
return
true
,
nil
}
targetUser
,
err
:=
GetUser
(
model
,
targetUserId
)
if
err
!=
nil
{
return
false
,
err
}
countries
:=
strings
.
Split
(
man
.
Countries
,
","
)
for
_
,
c
:=
range
countries
{
if
c
==
targetUser
.
Country
{
return
true
,
nil
}
}
return
false
,
nil
}
func
GetSuperManagerAll
(
model
*
domain
.
Model
)
([]
uint64
,
error
)
{
superManagers
:=
[]
SuperManager
{}
if
err
:=
model
.
Db
.
Model
(
&
SuperManager
{})
.
Find
(
&
superManagers
)
.
Error
;
err
!=
nil
{
...
...
domain/service/group_s/group_op.go
View file @
8f1ffffb
...
...
@@ -401,7 +401,7 @@ func (s *GroupService) GroupKick(groupUuid string, userId uint64, userExternalId
}
//超级管理人,无敌状态
if
flag
,
err
:=
user_m
.
IsSuperManager
(
model
,
u
serId
);
err
!=
nil
{
if
flag
,
err
:=
user_m
.
IsSuperManager
V2
(
model
,
userId
,
beKickU
serId
);
err
!=
nil
{
return
err
}
else
if
!
flag
{
//判断权限
...
...
route/group_r/group_op.go
View file @
8f1ffffb
...
...
@@ -878,14 +878,14 @@ func SearchGroup(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
}
if
owner
.
Status
==
user_e
.
UserStatusFrozen
{
if
flag
,
_
:=
user_m
.
IsSuperManager
(
model
,
myUserId
);
!
flag
{
if
flag
,
_
:=
user_m
.
IsSuperManager
V2
(
model
,
myUserId
,
owner
.
ID
);
!
flag
{
// 被封锁的用户,除了超管账户,其它用户搜索他的群组和个人ID,搜索结果为空
resp
.
ResponsePageOk
(
c
,
result
,
uint
(
total
),
1
)
return
myContext
,
nil
}
}
if
group_m
.
IsHiddenGroupBy
(
model
,
g
.
ImGroupId
)
{
if
flag
,
_
:=
user_m
.
IsSuperManager
(
model
,
myUserId
);
!
flag
{
if
flag
,
_
:=
user_m
.
IsSuperManager
V2
(
model
,
myUserId
,
g
.
Owner
);
!
flag
{
// 被隐藏的用户,除了超管账户,其它用户搜索他的群组和个人ID,搜索结果为空
resp
.
ResponsePageOk
(
c
,
result
,
uint
(
total
),
1
)
return
myContext
,
nil
...
...
route/group_r/group_setting.go
View file @
8f1ffffb
...
...
@@ -543,7 +543,7 @@ func AddGroupBlacklist(c *gin.Context) (*mycontext.MyContext, error) {
// 检查是否可以对svip6进行操作 optUserId:被操作的用户id
func
CheckOptToSvip6
(
model
*
domain
.
Model
,
userId
,
optUserId
uint64
,
lang
string
,
privilegeId
int
)
error
{
// 是否超管
isM
,
err
:=
user_m
.
IsSuperManager
(
model
,
u
serId
)
isM
,
err
:=
user_m
.
IsSuperManager
V2
(
model
,
userId
,
optU
serId
)
if
err
!=
nil
{
return
err
}
...
...