Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
9185e5d2
提交
9185e5d2
authored
2月 02, 2023
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善 RoleServiceImpl 单元测试
上级
71550a3c
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
52 行增加
和
70 行删除
+52
-70
BpmTaskAssignRuleServiceImpl.java
.../bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
+1
-1
RoleApi.java
...n/iocoder/yudao/module/system/api/permission/RoleApi.java
+1
-1
MenuIdEnum.java
...oder/yudao/module/system/enums/permission/MenuIdEnum.java
+0
-20
RoleApiImpl.java
...coder/yudao/module/system/api/permission/RoleApiImpl.java
+2
-2
AuthController.java
...o/module/system/controller/admin/auth/AuthController.java
+1
-1
RoleController.java
...le/system/controller/admin/permission/RoleController.java
+3
-3
UserProfileController.java
...e/system/controller/admin/user/UserProfileController.java
+1
-1
AuthConvert.java
...iocoder/yudao/module/system/convert/auth/AuthConvert.java
+7
-5
PermissionServiceImpl.java
...dule/system/service/permission/PermissionServiceImpl.java
+3
-3
RoleService.java
...r/yudao/module/system/service/permission/RoleService.java
+4
-4
RoleServiceImpl.java
...dao/module/system/service/permission/RoleServiceImpl.java
+20
-20
TenantServiceImpl.java
...yudao/module/system/service/tenant/TenantServiceImpl.java
+1
-1
PermissionServiceTest.java
...dule/system/service/permission/PermissionServiceTest.java
+7
-7
RoleServiceImplTest.java
...module/system/service/permission/RoleServiceImplTest.java
+0
-0
TenantServiceImplTest.java
...o/module/system/service/tenant/TenantServiceImplTest.java
+1
-1
没有找到文件。
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
浏览文件 @
9185e5d2
...
@@ -213,7 +213,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
...
@@ -213,7 +213,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
private
void
validTaskAssignRuleOptions
(
Integer
type
,
Set
<
Long
>
options
)
{
private
void
validTaskAssignRuleOptions
(
Integer
type
,
Set
<
Long
>
options
)
{
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
ROLE
.
getType
()))
{
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
ROLE
.
getType
()))
{
roleApi
.
validRole
s
(
options
);
roleApi
.
validRole
List
(
options
);
}
else
if
(
ObjectUtils
.
equalsAny
(
type
,
BpmTaskAssignRuleTypeEnum
.
DEPT_MEMBER
.
getType
(),
}
else
if
(
ObjectUtils
.
equalsAny
(
type
,
BpmTaskAssignRuleTypeEnum
.
DEPT_MEMBER
.
getType
(),
BpmTaskAssignRuleTypeEnum
.
DEPT_LEADER
.
getType
()))
{
BpmTaskAssignRuleTypeEnum
.
DEPT_LEADER
.
getType
()))
{
deptApi
.
validateDeptList
(
options
);
deptApi
.
validateDeptList
(
options
);
...
...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java
浏览文件 @
9185e5d2
...
@@ -20,6 +20,6 @@ public interface RoleApi {
...
@@ -20,6 +20,6 @@ public interface RoleApi {
@GetMapping
(
PREFIX
+
"/valid"
)
@GetMapping
(
PREFIX
+
"/valid"
)
@ApiOperation
(
"校验角色是否合法"
)
@ApiOperation
(
"校验角色是否合法"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"角色编号数组"
,
example
=
"1,2"
,
required
=
true
,
allowMultiple
=
true
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"角色编号数组"
,
example
=
"1,2"
,
required
=
true
,
allowMultiple
=
true
)
CommonResult
<
Boolean
>
validRole
s
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
CommonResult
<
Boolean
>
validRole
List
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
}
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/permission/MenuIdEnum.java
deleted
100644 → 0
浏览文件 @
71550a3c
package
cn
.
iocoder
.
yudao
.
module
.
system
.
enums
.
permission
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* Menu 编号枚举
*/
@Getter
@AllArgsConstructor
public
enum
MenuIdEnum
{
/**
* 根节点
*/
ROOT
(
0L
);
private
final
Long
id
;
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java
浏览文件 @
9185e5d2
...
@@ -22,8 +22,8 @@ public class RoleApiImpl implements RoleApi {
...
@@ -22,8 +22,8 @@ public class RoleApiImpl implements RoleApi {
private
RoleService
roleService
;
private
RoleService
roleService
;
@Override
@Override
public
CommonResult
<
Boolean
>
validRole
s
(
Collection
<
Long
>
ids
)
{
public
CommonResult
<
Boolean
>
validRole
List
(
Collection
<
Long
>
ids
)
{
roleService
.
valid
Roles
(
ids
);
roleService
.
valid
ateRoleList
(
ids
);
return
success
(
true
);
return
success
(
true
);
}
}
}
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
浏览文件 @
9185e5d2
...
@@ -98,7 +98,7 @@ public class AuthController {
...
@@ -98,7 +98,7 @@ public class AuthController {
}
}
// 获得角色列表
// 获得角色列表
Set
<
Long
>
roleIds
=
permissionService
.
getUserRoleIdsFromCache
(
getLoginUserId
(),
singleton
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
Set
<
Long
>
roleIds
=
permissionService
.
getUserRoleIdsFromCache
(
getLoginUserId
(),
singleton
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
List
<
RoleDO
>
roleList
=
roleService
.
getRole
s
FromCache
(
roleIds
);
List
<
RoleDO
>
roleList
=
roleService
.
getRole
List
FromCache
(
roleIds
);
// 获得菜单列表
// 获得菜单列表
List
<
MenuDO
>
menuList
=
permissionService
.
getRoleMenuListFromCache
(
roleIds
,
List
<
MenuDO
>
menuList
=
permissionService
.
getRoleMenuListFromCache
(
roleIds
,
SetUtils
.
asSet
(
MenuTypeEnum
.
DIR
.
getType
(),
MenuTypeEnum
.
MENU
.
getType
(),
MenuTypeEnum
.
BUTTON
.
getType
()),
SetUtils
.
asSet
(
MenuTypeEnum
.
DIR
.
getType
(),
MenuTypeEnum
.
MENU
.
getType
(),
MenuTypeEnum
.
BUTTON
.
getType
()),
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java
浏览文件 @
9185e5d2
...
@@ -20,12 +20,12 @@ import javax.annotation.Resource;
...
@@ -20,12 +20,12 @@ import javax.annotation.Resource;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
operatelog
.
core
.
enums
.
OperateTypeEnum
.
EXPORT
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
operatelog
.
core
.
enums
.
OperateTypeEnum
.
EXPORT
;
import
static
java
.
util
.
Collections
.
singleton
;
@Api
(
tags
=
"管理后台 - 角色"
)
@Api
(
tags
=
"管理后台 - 角色"
)
@RestController
@RestController
...
@@ -85,9 +85,9 @@ public class RoleController {
...
@@ -85,9 +85,9 @@ public class RoleController {
@GetMapping
(
"/list-all-simple"
)
@GetMapping
(
"/list-all-simple"
)
@ApiOperation
(
value
=
"获取角色精简信息列表"
,
notes
=
"只包含被开启的角色,主要用于前端的下拉选项"
)
@ApiOperation
(
value
=
"获取角色精简信息列表"
,
notes
=
"只包含被开启的角色,主要用于前端的下拉选项"
)
public
CommonResult
<
List
<
RoleSimpleRespVO
>>
getSimpleRole
s
()
{
public
CommonResult
<
List
<
RoleSimpleRespVO
>>
getSimpleRole
List
()
{
// 获得角色列表,只要开启状态的
// 获得角色列表,只要开启状态的
List
<
RoleDO
>
list
=
roleService
.
getRole
s
(
Collections
.
singleton
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
List
<
RoleDO
>
list
=
roleService
.
getRole
ListByStatus
(
singleton
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
// 排序后,返回给前端
// 排序后,返回给前端
list
.
sort
(
Comparator
.
comparing
(
RoleDO:
:
getSort
));
list
.
sort
(
Comparator
.
comparing
(
RoleDO:
:
getSort
));
return
success
(
RoleConvert
.
INSTANCE
.
convertList02
(
list
));
return
success
(
RoleConvert
.
INSTANCE
.
convertList02
(
list
));
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java
浏览文件 @
9185e5d2
...
@@ -63,7 +63,7 @@ public class UserProfileController {
...
@@ -63,7 +63,7 @@ public class UserProfileController {
AdminUserDO
user
=
userService
.
getUser
(
getLoginUserId
());
AdminUserDO
user
=
userService
.
getUser
(
getLoginUserId
());
UserProfileRespVO
resp
=
UserConvert
.
INSTANCE
.
convert03
(
user
);
UserProfileRespVO
resp
=
UserConvert
.
INSTANCE
.
convert03
(
user
);
// 获得用户角色
// 获得用户角色
List
<
RoleDO
>
userRoles
=
roleService
.
getRole
s
FromCache
(
permissionService
.
getUserRoleIdListByUserId
(
user
.
getId
()));
List
<
RoleDO
>
userRoles
=
roleService
.
getRole
List
FromCache
(
permissionService
.
getUserRoleIdListByUserId
(
user
.
getId
()));
resp
.
setRoles
(
UserConvert
.
INSTANCE
.
convertList
(
userRoles
));
resp
.
setRoles
(
UserConvert
.
INSTANCE
.
convertList
(
userRoles
));
// 获得部门信息
// 获得部门信息
if
(
user
.
getDeptId
()
!=
null
)
{
if
(
user
.
getDeptId
()
!=
null
)
{
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java
浏览文件 @
9185e5d2
...
@@ -9,13 +9,15 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
...
@@ -9,13 +9,15 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import
cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO
;
import
cn.iocoder.yudao.module.system.enums.permission.MenuIdEnum
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
import
org.mapstruct.factory.Mappers
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.*
;
import
java.util.*
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
collection
.
CollectionUtils
.*;
import
static
cn
.
iocoder
.
yudao
.
module
.
system
.
dal
.
dataobject
.
permission
.
MenuDO
.
ID_ROOT
;
@Mapper
@Mapper
public
interface
AuthConvert
{
public
interface
AuthConvert
{
...
@@ -26,8 +28,8 @@ public interface AuthConvert {
...
@@ -26,8 +28,8 @@ public interface AuthConvert {
default
AuthPermissionInfoRespVO
convert
(
AdminUserDO
user
,
List
<
RoleDO
>
roleList
,
List
<
MenuDO
>
menuList
)
{
default
AuthPermissionInfoRespVO
convert
(
AdminUserDO
user
,
List
<
RoleDO
>
roleList
,
List
<
MenuDO
>
menuList
)
{
return
AuthPermissionInfoRespVO
.
builder
()
return
AuthPermissionInfoRespVO
.
builder
()
.
user
(
AuthPermissionInfoRespVO
.
UserVO
.
builder
().
id
(
user
.
getId
()).
nickname
(
user
.
getNickname
()).
avatar
(
user
.
getAvatar
()).
build
())
.
user
(
AuthPermissionInfoRespVO
.
UserVO
.
builder
().
id
(
user
.
getId
()).
nickname
(
user
.
getNickname
()).
avatar
(
user
.
getAvatar
()).
build
())
.
roles
(
CollectionUtils
.
convertSet
(
roleList
,
RoleDO:
:
getCode
))
.
roles
(
convertSet
(
roleList
,
RoleDO:
:
getCode
))
.
permissions
(
CollectionUtils
.
convertSet
(
menuList
,
MenuDO:
:
getPermission
))
.
permissions
(
convertSet
(
menuList
,
MenuDO:
:
getPermission
))
.
build
();
.
build
();
}
}
...
@@ -47,7 +49,7 @@ public interface AuthConvert {
...
@@ -47,7 +49,7 @@ public interface AuthConvert {
Map
<
Long
,
AuthMenuRespVO
>
treeNodeMap
=
new
LinkedHashMap
<>();
Map
<
Long
,
AuthMenuRespVO
>
treeNodeMap
=
new
LinkedHashMap
<>();
menuList
.
forEach
(
menu
->
treeNodeMap
.
put
(
menu
.
getId
(),
AuthConvert
.
INSTANCE
.
convertTreeNode
(
menu
)));
menuList
.
forEach
(
menu
->
treeNodeMap
.
put
(
menu
.
getId
(),
AuthConvert
.
INSTANCE
.
convertTreeNode
(
menu
)));
// 处理父子关系
// 处理父子关系
treeNodeMap
.
values
().
stream
().
filter
(
node
->
!
node
.
getParentId
().
equals
(
MenuIdEnum
.
ROOT
.
getId
()
)).
forEach
(
childNode
->
{
treeNodeMap
.
values
().
stream
().
filter
(
node
->
!
node
.
getParentId
().
equals
(
ID_ROOT
)).
forEach
(
childNode
->
{
// 获得父节点
// 获得父节点
AuthMenuRespVO
parentNode
=
treeNodeMap
.
get
(
childNode
.
getParentId
());
AuthMenuRespVO
parentNode
=
treeNodeMap
.
get
(
childNode
.
getParentId
());
if
(
parentNode
==
null
)
{
if
(
parentNode
==
null
)
{
...
@@ -62,7 +64,7 @@ public interface AuthConvert {
...
@@ -62,7 +64,7 @@ public interface AuthConvert {
parentNode
.
getChildren
().
add
(
childNode
);
parentNode
.
getChildren
().
add
(
childNode
);
});
});
// 获得到所有的根节点
// 获得到所有的根节点
return
CollectionUtils
.
filterList
(
treeNodeMap
.
values
(),
node
->
MenuIdEnum
.
ROOT
.
getId
()
.
equals
(
node
.
getParentId
()));
return
filterList
(
treeNodeMap
.
values
(),
node
->
ID_ROOT
.
equals
(
node
.
getParentId
()));
}
}
SocialUserBindReqDTO
convert
(
Long
userId
,
Integer
userType
,
AuthSocialBindLoginReqVO
reqVO
);
SocialUserBindReqDTO
convert
(
Long
userId
,
Integer
userType
,
AuthSocialBindLoginReqVO
reqVO
);
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java
浏览文件 @
9185e5d2
...
@@ -158,7 +158,7 @@ public class PermissionServiceImpl implements PermissionService {
...
@@ -158,7 +158,7 @@ public class PermissionServiceImpl implements PermissionService {
}
}
// 判断角色是否包含超级管理员。如果是超级管理员,获取到全部
// 判断角色是否包含超级管理员。如果是超级管理员,获取到全部
List
<
RoleDO
>
roleList
=
roleService
.
getRole
s
FromCache
(
roleIds
);
List
<
RoleDO
>
roleList
=
roleService
.
getRole
List
FromCache
(
roleIds
);
if
(
roleService
.
hasAnySuperAdmin
(
roleList
))
{
if
(
roleService
.
hasAnySuperAdmin
(
roleList
))
{
return
menuService
.
getMenuListFromCache
(
menuTypes
,
menusStatuses
);
return
menuService
.
getMenuListFromCache
(
menuTypes
,
menusStatuses
);
}
}
...
@@ -371,7 +371,7 @@ public class PermissionServiceImpl implements PermissionService {
...
@@ -371,7 +371,7 @@ public class PermissionServiceImpl implements PermissionService {
if
(
roleService
.
hasAnySuperAdmin
(
roleIds
))
{
if
(
roleService
.
hasAnySuperAdmin
(
roleIds
))
{
return
true
;
return
true
;
}
}
Set
<
String
>
userRoles
=
convertSet
(
roleService
.
getRole
s
FromCache
(
roleIds
),
Set
<
String
>
userRoles
=
convertSet
(
roleService
.
getRole
List
FromCache
(
roleIds
),
RoleDO:
:
getCode
);
RoleDO:
:
getCode
);
return
CollUtil
.
containsAny
(
userRoles
,
Sets
.
newHashSet
(
roles
));
return
CollUtil
.
containsAny
(
userRoles
,
Sets
.
newHashSet
(
roles
));
}
}
...
@@ -388,7 +388,7 @@ public class PermissionServiceImpl implements PermissionService {
...
@@ -388,7 +388,7 @@ public class PermissionServiceImpl implements PermissionService {
result
.
setSelf
(
true
);
result
.
setSelf
(
true
);
return
result
;
return
result
;
}
}
List
<
RoleDO
>
roles
=
roleService
.
getRole
s
FromCache
(
roleIds
);
List
<
RoleDO
>
roles
=
roleService
.
getRole
List
FromCache
(
roleIds
);
// 获得用户的部门编号的缓存,通过 Guava 的 Suppliers 惰性求值,即有且仅有第一次发起 DB 的查询
// 获得用户的部门编号的缓存,通过 Guava 的 Suppliers 惰性求值,即有且仅有第一次发起 DB 的查询
Supplier
<
Long
>
userDeptIdCache
=
Suppliers
.
memoize
(()
->
userService
.
getUser
(
userId
).
getDeptId
());
Supplier
<
Long
>
userDeptIdCache
=
Suppliers
.
memoize
(()
->
userService
.
getUser
(
userId
).
getDeptId
());
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java
浏览文件 @
9185e5d2
...
@@ -79,7 +79,7 @@ public interface RoleService {
...
@@ -79,7 +79,7 @@ public interface RoleService {
* @param statuses 筛选的状态。允许空,空时不筛选
* @param statuses 筛选的状态。允许空,空时不筛选
* @return 角色列表
* @return 角色列表
*/
*/
List
<
RoleDO
>
getRoles
(
@Nullable
Collection
<
Integer
>
statuses
);
List
<
RoleDO
>
getRole
ListByStatu
s
(
@Nullable
Collection
<
Integer
>
statuses
);
/**
/**
* 获得角色数组,从缓存中
* 获得角色数组,从缓存中
...
@@ -87,7 +87,7 @@ public interface RoleService {
...
@@ -87,7 +87,7 @@ public interface RoleService {
* @param ids 角色编号数组
* @param ids 角色编号数组
* @return 角色数组
* @return 角色数组
*/
*/
List
<
RoleDO
>
getRole
s
FromCache
(
Collection
<
Long
>
ids
);
List
<
RoleDO
>
getRole
List
FromCache
(
Collection
<
Long
>
ids
);
/**
/**
* 判断角色数组中,是否有超级管理员
* 判断角色数组中,是否有超级管理员
...
@@ -104,7 +104,7 @@ public interface RoleService {
...
@@ -104,7 +104,7 @@ public interface RoleService {
* @return 是否有管理员
* @return 是否有管理员
*/
*/
default
boolean
hasAnySuperAdmin
(
Set
<
Long
>
ids
)
{
default
boolean
hasAnySuperAdmin
(
Set
<
Long
>
ids
)
{
return
hasAnySuperAdmin
(
getRole
s
FromCache
(
ids
));
return
hasAnySuperAdmin
(
getRole
List
FromCache
(
ids
));
}
}
/**
/**
...
@@ -138,6 +138,6 @@ public interface RoleService {
...
@@ -138,6 +138,6 @@ public interface RoleService {
*
*
* @param ids 角色编号数组
* @param ids 角色编号数组
*/
*/
void
valid
Roles
(
Collection
<
Long
>
ids
);
void
valid
ateRoleList
(
Collection
<
Long
>
ids
);
}
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java
浏览文件 @
9185e5d2
...
@@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollectionUtil;
...
@@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollectionUtil;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.util.collection.CollectionUtils
;
import
cn.iocoder.yudao.framework.tenant.core.util.TenantUtils
;
import
cn.iocoder.yudao.framework.tenant.core.util.TenantUtils
;
import
cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleCreateReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleCreateReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleExportReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleExportReqVO
;
...
@@ -34,6 +33,7 @@ import java.util.*;
...
@@ -34,6 +33,7 @@ import java.util.*;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
collection
.
CollectionUtils
.
convertMap
;
import
static
cn
.
iocoder
.
yudao
.
module
.
system
.
enums
.
ErrorCodeConstants
.*;
import
static
cn
.
iocoder
.
yudao
.
module
.
system
.
enums
.
ErrorCodeConstants
.*;
/**
/**
...
@@ -76,7 +76,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -76,7 +76,7 @@ public class RoleServiceImpl implements RoleService {
log
.
info
(
"[initLocalCache][缓存角色,数量为:{}]"
,
roleList
.
size
());
log
.
info
(
"[initLocalCache][缓存角色,数量为:{}]"
,
roleList
.
size
());
// 第二步:构建缓存
// 第二步:构建缓存
roleCache
=
CollectionUtils
.
convertMap
(
roleList
,
RoleDO:
:
getId
);
roleCache
=
convertMap
(
roleList
,
RoleDO:
:
getId
);
});
});
}
}
...
@@ -84,7 +84,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -84,7 +84,7 @@ public class RoleServiceImpl implements RoleService {
@Transactional
@Transactional
public
Long
createRole
(
RoleCreateReqVO
reqVO
,
Integer
type
)
{
public
Long
createRole
(
RoleCreateReqVO
reqVO
,
Integer
type
)
{
// 校验角色
// 校验角色
checkDuplicateRol
e
(
reqVO
.
getName
(),
reqVO
.
getCode
(),
null
);
validateRoleDuplicat
e
(
reqVO
.
getName
(),
reqVO
.
getCode
(),
null
);
// 插入到数据库
// 插入到数据库
RoleDO
role
=
RoleConvert
.
INSTANCE
.
convert
(
reqVO
);
RoleDO
role
=
RoleConvert
.
INSTANCE
.
convert
(
reqVO
);
role
.
setType
(
ObjectUtil
.
defaultIfNull
(
type
,
RoleTypeEnum
.
CUSTOM
.
getType
()));
role
.
setType
(
ObjectUtil
.
defaultIfNull
(
type
,
RoleTypeEnum
.
CUSTOM
.
getType
()));
...
@@ -105,13 +105,13 @@ public class RoleServiceImpl implements RoleService {
...
@@ -105,13 +105,13 @@ public class RoleServiceImpl implements RoleService {
@Override
@Override
public
void
updateRole
(
RoleUpdateReqVO
reqVO
)
{
public
void
updateRole
(
RoleUpdateReqVO
reqVO
)
{
// 校验是否可以更新
// 校验是否可以更新
checkUpdateRol
e
(
reqVO
.
getId
());
validateRoleForUpdat
e
(
reqVO
.
getId
());
// 校验角色的唯一字段是否重复
// 校验角色的唯一字段是否重复
checkDuplicateRol
e
(
reqVO
.
getName
(),
reqVO
.
getCode
(),
reqVO
.
getId
());
validateRoleDuplicat
e
(
reqVO
.
getName
(),
reqVO
.
getCode
(),
reqVO
.
getId
());
// 更新到数据库
// 更新到数据库
RoleDO
updateObj
ect
=
RoleConvert
.
INSTANCE
.
convert
(
reqVO
);
RoleDO
updateObj
=
RoleConvert
.
INSTANCE
.
convert
(
reqVO
);
roleMapper
.
updateById
(
updateObj
ect
);
roleMapper
.
updateById
(
updateObj
);
// 发送刷新消息
// 发送刷新消息
roleProducer
.
sendRoleRefreshMessage
();
roleProducer
.
sendRoleRefreshMessage
();
}
}
...
@@ -119,12 +119,11 @@ public class RoleServiceImpl implements RoleService {
...
@@ -119,12 +119,11 @@ public class RoleServiceImpl implements RoleService {
@Override
@Override
public
void
updateRoleStatus
(
Long
id
,
Integer
status
)
{
public
void
updateRoleStatus
(
Long
id
,
Integer
status
)
{
// 校验是否可以更新
// 校验是否可以更新
checkUpdateRole
(
id
);
validateRoleForUpdate
(
id
);
// 更新状态
// 更新状态
RoleDO
updateObject
=
new
RoleDO
();
RoleDO
updateObj
=
new
RoleDO
().
setId
(
id
).
setStatus
(
status
);
updateObject
.
setId
(
id
);
roleMapper
.
updateById
(
updateObj
);
updateObject
.
setStatus
(
status
);
roleMapper
.
updateById
(
updateObject
);
// 发送刷新消息
// 发送刷新消息
roleProducer
.
sendRoleRefreshMessage
();
roleProducer
.
sendRoleRefreshMessage
();
}
}
...
@@ -132,7 +131,8 @@ public class RoleServiceImpl implements RoleService {
...
@@ -132,7 +131,8 @@ public class RoleServiceImpl implements RoleService {
@Override
@Override
public
void
updateRoleDataScope
(
Long
id
,
Integer
dataScope
,
Set
<
Long
>
dataScopeDeptIds
)
{
public
void
updateRoleDataScope
(
Long
id
,
Integer
dataScope
,
Set
<
Long
>
dataScopeDeptIds
)
{
// 校验是否可以更新
// 校验是否可以更新
checkUpdateRole
(
id
);
validateRoleForUpdate
(
id
);
// 更新数据范围
// 更新数据范围
RoleDO
updateObject
=
new
RoleDO
();
RoleDO
updateObject
=
new
RoleDO
();
updateObject
.
setId
(
id
);
updateObject
.
setId
(
id
);
...
@@ -147,7 +147,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -147,7 +147,7 @@ public class RoleServiceImpl implements RoleService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteRole
(
Long
id
)
{
public
void
deleteRole
(
Long
id
)
{
// 校验是否可以更新
// 校验是否可以更新
this
.
checkUpdateRol
e
(
id
);
validateRoleForUpdat
e
(
id
);
// 标记删除
// 标记删除
roleMapper
.
deleteById
(
id
);
roleMapper
.
deleteById
(
id
);
// 删除相关数据
// 删除相关数据
...
@@ -169,7 +169,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -169,7 +169,7 @@ public class RoleServiceImpl implements RoleService {
}
}
@Override
@Override
public
List
<
RoleDO
>
getRoles
(
@Nullable
Collection
<
Integer
>
statuses
)
{
public
List
<
RoleDO
>
getRole
ListByStatu
s
(
@Nullable
Collection
<
Integer
>
statuses
)
{
if
(
CollUtil
.
isEmpty
(
statuses
))
{
if
(
CollUtil
.
isEmpty
(
statuses
))
{
return
roleMapper
.
selectList
();
return
roleMapper
.
selectList
();
}
}
...
@@ -177,7 +177,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -177,7 +177,7 @@ public class RoleServiceImpl implements RoleService {
}
}
@Override
@Override
public
List
<
RoleDO
>
getRole
s
FromCache
(
Collection
<
Long
>
ids
)
{
public
List
<
RoleDO
>
getRole
List
FromCache
(
Collection
<
Long
>
ids
)
{
if
(
CollectionUtil
.
isEmpty
(
ids
))
{
if
(
CollectionUtil
.
isEmpty
(
ids
))
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
...
@@ -219,7 +219,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -219,7 +219,7 @@ public class RoleServiceImpl implements RoleService {
* @param id 角色编号
* @param id 角色编号
*/
*/
@VisibleForTesting
@VisibleForTesting
public
void
checkDuplicateRol
e
(
String
name
,
String
code
,
Long
id
)
{
void
validateRoleDuplicat
e
(
String
name
,
String
code
,
Long
id
)
{
// 0. 超级管理员,不允许创建
// 0. 超级管理员,不允许创建
if
(
RoleCodeEnum
.
isSuperAdmin
(
code
))
{
if
(
RoleCodeEnum
.
isSuperAdmin
(
code
))
{
throw
exception
(
ROLE_ADMIN_CODE_ERROR
,
code
);
throw
exception
(
ROLE_ADMIN_CODE_ERROR
,
code
);
...
@@ -246,7 +246,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -246,7 +246,7 @@ public class RoleServiceImpl implements RoleService {
* @param id 角色编号
* @param id 角色编号
*/
*/
@VisibleForTesting
@VisibleForTesting
public
void
checkUpdateRol
e
(
Long
id
)
{
void
validateRoleForUpdat
e
(
Long
id
)
{
RoleDO
roleDO
=
roleMapper
.
selectById
(
id
);
RoleDO
roleDO
=
roleMapper
.
selectById
(
id
);
if
(
roleDO
==
null
)
{
if
(
roleDO
==
null
)
{
throw
exception
(
ROLE_NOT_EXISTS
);
throw
exception
(
ROLE_NOT_EXISTS
);
...
@@ -258,13 +258,13 @@ public class RoleServiceImpl implements RoleService {
...
@@ -258,13 +258,13 @@ public class RoleServiceImpl implements RoleService {
}
}
@Override
@Override
public
void
valid
Roles
(
Collection
<
Long
>
ids
)
{
public
void
valid
ateRoleList
(
Collection
<
Long
>
ids
)
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
return
;
return
;
}
}
// 获得角色信息
// 获得角色信息
List
<
RoleDO
>
roles
=
roleMapper
.
selectBatchIds
(
ids
);
List
<
RoleDO
>
roles
=
roleMapper
.
selectBatchIds
(
ids
);
Map
<
Long
,
RoleDO
>
roleMap
=
CollectionUtils
.
convertMap
(
roles
,
RoleDO:
:
getId
);
Map
<
Long
,
RoleDO
>
roleMap
=
convertMap
(
roles
,
RoleDO:
:
getId
);
// 校验
// 校验
ids
.
forEach
(
id
->
{
ids
.
forEach
(
id
->
{
RoleDO
role
=
roleMap
.
get
(
id
);
RoleDO
role
=
roleMap
.
get
(
id
);
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java
浏览文件 @
9185e5d2
...
@@ -158,7 +158,7 @@ public class TenantServiceImpl implements TenantService {
...
@@ -158,7 +158,7 @@ public class TenantServiceImpl implements TenantService {
public
void
updateTenantRoleMenu
(
Long
tenantId
,
Set
<
Long
>
menuIds
)
{
public
void
updateTenantRoleMenu
(
Long
tenantId
,
Set
<
Long
>
menuIds
)
{
TenantUtils
.
execute
(
tenantId
,
()
->
{
TenantUtils
.
execute
(
tenantId
,
()
->
{
// 获得所有角色
// 获得所有角色
List
<
RoleDO
>
roles
=
roleService
.
getRoles
(
null
);
List
<
RoleDO
>
roles
=
roleService
.
getRole
ListByStatu
s
(
null
);
roles
.
forEach
(
role
->
Assert
.
isTrue
(
tenantId
.
equals
(
role
.
getTenantId
()),
"角色({}/{}) 租户不匹配"
,
roles
.
forEach
(
role
->
Assert
.
isTrue
(
tenantId
.
equals
(
role
.
getTenantId
()),
"角色({}/{}) 租户不匹配"
,
role
.
getId
(),
role
.
getTenantId
(),
tenantId
));
// 兜底校验
role
.
getId
(),
role
.
getTenantId
(),
tenantId
));
// 兜底校验
// 重新分配每个角色的权限
// 重新分配每个角色的权限
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java
浏览文件 @
9185e5d2
...
@@ -106,7 +106,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -106,7 +106,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
Collection
<
Integer
>
menusStatuses
=
asList
(
0
,
1
);
Collection
<
Integer
>
menusStatuses
=
asList
(
0
,
1
);
// mock 方法
// mock 方法
List
<
RoleDO
>
roleList
=
singletonList
(
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setId
(
100L
)));
List
<
RoleDO
>
roleList
=
singletonList
(
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setId
(
100L
)));
when
(
roleService
.
getRole
s
FromCache
(
eq
(
roleIds
))).
thenReturn
(
roleList
);
when
(
roleService
.
getRole
List
FromCache
(
eq
(
roleIds
))).
thenReturn
(
roleList
);
when
(
roleService
.
hasAnySuperAdmin
(
same
(
roleList
))).
thenReturn
(
true
);
when
(
roleService
.
hasAnySuperAdmin
(
same
(
roleList
))).
thenReturn
(
true
);
List
<
MenuDO
>
menuList
=
randomPojoList
(
MenuDO
.
class
);
List
<
MenuDO
>
menuList
=
randomPojoList
(
MenuDO
.
class
);
when
(
menuService
.
getMenuListFromCache
(
eq
(
menuTypes
),
eq
(
menusStatuses
))).
thenReturn
(
menuList
);
when
(
menuService
.
getMenuListFromCache
(
eq
(
menuTypes
),
eq
(
menusStatuses
))).
thenReturn
(
menuList
);
...
@@ -419,7 +419,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -419,7 +419,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
when
(
roleService
.
getRoleFromCache
(
eq
(
100L
))).
thenReturn
(
role
);
when
(
roleService
.
getRoleFromCache
(
eq
(
100L
))).
thenReturn
(
role
);
// mock 其它方法
// mock 其它方法
when
(
roleService
.
getRole
s
FromCache
(
eq
(
asSet
(
100L
)))).
thenReturn
(
singletonList
(
role
));
when
(
roleService
.
getRole
List
FromCache
(
eq
(
asSet
(
100L
)))).
thenReturn
(
singletonList
(
role
));
// 调用
// 调用
boolean
has
=
permissionService
.
hasAnyRoles
(
userId
,
roles
);
boolean
has
=
permissionService
.
hasAnyRoles
(
userId
,
roles
);
...
@@ -436,7 +436,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -436,7 +436,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
// mock 获得用户的角色
// mock 获得用户的角色
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
ALL
.
getScope
())
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
ALL
.
getScope
())
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
when
(
roleService
.
getRole
s
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRole
List
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
// 调用
// 调用
...
@@ -456,7 +456,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -456,7 +456,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
// mock 获得用户的角色
// mock 获得用户的角色
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
DEPT_CUSTOM
.
getScope
())
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
DEPT_CUSTOM
.
getScope
())
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
when
(
roleService
.
getRole
s
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRole
List
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
// mock 部门的返回
// mock 部门的返回
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
...
@@ -480,7 +480,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -480,7 +480,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
// mock 获得用户的角色
// mock 获得用户的角色
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
DEPT_ONLY
.
getScope
())
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
DEPT_ONLY
.
getScope
())
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
when
(
roleService
.
getRole
s
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRole
List
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
// mock 部门的返回
// mock 部门的返回
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
...
@@ -503,7 +503,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -503,7 +503,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
// mock 获得用户的角色
// mock 获得用户的角色
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
DEPT_AND_CHILD
.
getScope
())
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
DEPT_AND_CHILD
.
getScope
())
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
when
(
roleService
.
getRole
s
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRole
List
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
// mock 部门的返回
// mock 部门的返回
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
...
@@ -531,7 +531,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
...
@@ -531,7 +531,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
// mock 获得用户的角色
// mock 获得用户的角色
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
SELF
.
getScope
())
RoleDO
roleDO
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setDataScope
(
DataScopeEnum
.
SELF
.
getScope
())
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
when
(
roleService
.
getRole
s
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRole
List
FromCache
(
eq
(
singleton
(
2L
)))).
thenReturn
(
singletonList
(
roleDO
));
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
when
(
roleService
.
getRoleFromCache
(
eq
(
2L
))).
thenReturn
(
roleDO
);
// 调用
// 调用
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceTest.java
→
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleService
Impl
Test.java
浏览文件 @
9185e5d2
差异被折叠。
点击展开。
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java
浏览文件 @
9185e5d2
...
@@ -196,7 +196,7 @@ public class TenantServiceImplTest extends BaseDbUnitTest {
...
@@ -196,7 +196,7 @@ public class TenantServiceImplTest extends BaseDbUnitTest {
role100
.
setTenantId
(
dbTenant
.
getId
());
role100
.
setTenantId
(
dbTenant
.
getId
());
RoleDO
role101
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setId
(
101L
));
RoleDO
role101
=
randomPojo
(
RoleDO
.
class
,
o
->
o
.
setId
(
101L
));
role101
.
setTenantId
(
dbTenant
.
getId
());
role101
.
setTenantId
(
dbTenant
.
getId
());
when
(
roleService
.
getRole
s
(
isNull
())).
thenReturn
(
asList
(
role100
,
role101
));
when
(
roleService
.
getRole
List
(
isNull
())).
thenReturn
(
asList
(
role100
,
role101
));
// mock 每个角色的权限
// mock 每个角色的权限
when
(
permissionService
.
getRoleMenuIds
(
eq
(
101L
))).
thenReturn
(
asSet
(
201L
,
202L
));
when
(
permissionService
.
getRoleMenuIds
(
eq
(
101L
))).
thenReturn
(
asSet
(
201L
,
202L
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论