切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
2ffe21e34b08e35daada40f95b0adc3d2a10a026
1 个父辈
872b4691
1. 添加超级管理员类型
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
28 行增加
和
12 行删除
pkg/application/role/role_user_service.go
pkg/application/role/role_user_service.go
查看文件 @
2ffe21e
...
...
@@ -117,20 +117,28 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface
// GetHrBp 当前操作人是否拥有HR-BP权限 (1表示有权限)
func
GetHrBp
(
transactionContext
application
.
TransactionContext
,
companyId
int
,
operatorId
int
)
(
int
,
error
)
{
roleRepo
:=
factory
.
CreateRoleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
roleUserRepo
:=
factory
.
CreateRoleUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
roleList
,
err
:=
roleRepo
.
Find
(
map
[
string
]
interface
{}{
"type"
:
domain
.
RoleTypeSystem
,
"companyId"
:
companyId
})
roleRepository
:=
factory
.
CreateRoleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
roleUserRepository
:=
factory
.
CreateRoleUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
roles
,
err
:=
roleRepository
.
Find
(
map
[
string
]
interface
{}{
"type"
:
domain
.
RoleTypeSystem
,
"companyId"
:
companyId
})
if
err
!=
nil
{
return
-
1
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取角色信息列表"
+
err
.
Error
())
}
_
,
userRoleList
,
err
:=
roleUserRepo
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
companyId
,
"userId"
:
operatorId
})
if
len
(
roles
)
==
0
{
return
-
1
,
nil
}
_
,
userRoles
,
err
:=
roleUserRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
companyId
,
"userId"
:
operatorId
})
if
err
!=
nil
{
return
-
1
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取用户的角色信息列表"
+
err
.
Error
())
}
if
len
(
userRoles
)
==
0
{
return
-
1
,
nil
}
hrBp
:=
-
1
loopFinish
:
for
_
,
userRole
:=
range
userRoleList
{
for
_
,
role
:=
range
roleList
{
for
_
,
userRole
:=
range
userRoles
{
for
_
,
role
:=
range
roles
{
if
userRole
.
RoleId
==
role
.
Id
{
hrBp
=
domain
.
RoleTypeSystem
break
loopFinish
...
...
@@ -142,20 +150,28 @@ loopFinish:
// GetSuperAdmin 当前操作人是否拥有超级管理员权限 (2表示有权限)
func
GetSuperAdmin
(
transactionContext
application
.
TransactionContext
,
companyId
int
,
operatorId
int
)
(
int
,
error
)
{
roleRepo
:=
factory
.
CreateRoleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
roleUserRepo
:=
factory
.
CreateRoleUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
roleList
,
err
:=
roleRepo
.
Find
(
map
[
string
]
interface
{}{
"type"
:
domain
.
RoleTypeSuperAdmin
,
"companyId"
:
companyId
})
roleRepository
:=
factory
.
CreateRoleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
roleUserRepository
:=
factory
.
CreateRoleUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
roles
,
err
:=
roleRepository
.
Find
(
map
[
string
]
interface
{}{
"type"
:
domain
.
RoleTypeSuperAdmin
,
"companyId"
:
companyId
})
if
err
!=
nil
{
return
-
1
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取角色信息列表"
+
err
.
Error
())
}
_
,
userRoleList
,
err
:=
roleUserRepo
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
companyId
,
"userId"
:
operatorId
})
if
len
(
roles
)
==
0
{
return
-
1
,
nil
}
_
,
userRoles
,
err
:=
roleUserRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
companyId
,
"userId"
:
operatorId
})
if
err
!=
nil
{
return
-
1
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取用户的角色信息列表"
+
err
.
Error
())
}
if
len
(
userRoles
)
==
0
{
return
-
1
,
nil
}
superAdmin
:=
-
1
loopFinish
:
for
_
,
userRole
:=
range
userRoleList
{
for
_
,
role
:=
range
roleList
{
for
_
,
userRole
:=
range
userRoles
{
for
_
,
role
:=
range
roles
{
if
userRole
.
RoleId
==
role
.
Id
{
superAdmin
=
domain
.
RoleTypeSuperAdmin
break
loopFinish
...
...
请
注册
或
登录
后发表评论