Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
7f6d64e9
提交
7f6d64e9
authored
1月 31, 2023
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善 DeptServiceImpl 单元测试
上级
2edf53a4
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
62 行增加
和
79 行删除
+62
-79
BpmTaskAssignRuleServiceImpl.java
.../bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
+2
-2
BpmTaskAssignRuleServiceImplTest.java
.../service/definition/BpmTaskAssignRuleServiceImplTest.java
+1
-1
DeptApi.java
...java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java
+3
-3
DeptApiImpl.java
.../cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
+4
-4
DeptController.java
...o/module/system/controller/admin/dept/DeptController.java
+2
-2
DeptService.java
...iocoder/yudao/module/system/service/dept/DeptService.java
+18
-25
DeptServiceImpl.java
...der/yudao/module/system/service/dept/DeptServiceImpl.java
+25
-35
PermissionServiceImpl.java
...dule/system/service/permission/PermissionServiceImpl.java
+1
-1
AdminUserServiceImpl.java
...udao/module/system/service/user/AdminUserServiceImpl.java
+2
-2
DeptServiceImplTest.java
...yudao/module/system/service/dept/DeptServiceImplTest.java
+0
-0
PermissionServiceTest.java
...dule/system/service/permission/PermissionServiceTest.java
+1
-1
AdminUserServiceImplTest.java
.../module/system/service/user/AdminUserServiceImplTest.java
+3
-3
没有找到文件。
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
浏览文件 @
7f6d64e9
...
...
@@ -216,7 +216,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
roleApi
.
validRoles
(
options
);
}
else
if
(
ObjectUtils
.
equalsAny
(
type
,
BpmTaskAssignRuleTypeEnum
.
DEPT_MEMBER
.
getType
(),
BpmTaskAssignRuleTypeEnum
.
DEPT_LEADER
.
getType
()))
{
deptApi
.
valid
Depts
(
options
);
deptApi
.
valid
ateDeptList
(
options
);
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
POST
.
getType
()))
{
postApi
.
validPosts
(
options
);
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
USER
.
getType
()))
{
...
...
@@ -293,7 +293,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
}
private
Set
<
Long
>
calculateTaskCandidateUsersByDeptLeader
(
BpmTaskAssignRuleDO
rule
)
{
List
<
DeptRespDTO
>
depts
=
deptApi
.
getDept
s
(
rule
.
getOptions
()).
getCheckedData
();
List
<
DeptRespDTO
>
depts
=
deptApi
.
getDept
List
(
rule
.
getOptions
()).
getCheckedData
();
return
convertSet
(
depts
,
DeptRespDTO:
:
getLeaderUserId
);
}
...
...
yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImplTest.java
浏览文件 @
7f6d64e9
...
...
@@ -104,7 +104,7 @@ public class BpmTaskAssignRuleServiceImplTest extends BaseDbUnitTest {
// mock 方法
DeptRespDTO
dept1
=
randomPojo
(
DeptRespDTO
.
class
,
o
->
o
.
setLeaderUserId
(
11L
));
DeptRespDTO
dept2
=
randomPojo
(
DeptRespDTO
.
class
,
o
->
o
.
setLeaderUserId
(
22L
));
when
(
deptApi
.
getDept
s
(
eq
(
rule
.
getOptions
()))).
thenReturn
(
success
(
Arrays
.
asList
(
dept1
,
dept2
)));
when
(
deptApi
.
getDept
List
(
eq
(
rule
.
getOptions
()))).
thenReturn
(
success
(
Arrays
.
asList
(
dept1
,
dept2
)));
mockGetUserMap
(
asSet
(
11L
,
22L
));
// 调用
...
...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java
浏览文件 @
7f6d64e9
...
...
@@ -30,12 +30,12 @@ public interface DeptApi {
@GetMapping
(
PREFIX
+
"/list"
)
@ApiOperation
(
"获得部门信息数组"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"部门编号数组"
,
example
=
"1,2"
,
required
=
true
,
allowMultiple
=
true
)
CommonResult
<
List
<
DeptRespDTO
>>
getDept
s
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
CommonResult
<
List
<
DeptRespDTO
>>
getDept
List
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
@GetMapping
(
PREFIX
+
"/valid"
)
@ApiOperation
(
"校验部门是否合法"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"部门编号数组"
,
example
=
"1,2"
,
required
=
true
,
allowMultiple
=
true
)
CommonResult
<
Boolean
>
valid
Depts
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
CommonResult
<
Boolean
>
valid
ateDeptList
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
/**
* 获得指定编号的部门 Map
...
...
@@ -44,7 +44,7 @@ public interface DeptApi {
* @return 部门 Map
*/
default
Map
<
Long
,
DeptRespDTO
>
getDeptMap
(
Set
<
Long
>
ids
)
{
return
CollectionUtils
.
convertMap
(
getDept
s
(
ids
).
getCheckedData
(),
DeptRespDTO:
:
getId
);
return
CollectionUtils
.
convertMap
(
getDept
List
(
ids
).
getCheckedData
(),
DeptRespDTO:
:
getId
);
}
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
浏览文件 @
7f6d64e9
...
...
@@ -31,14 +31,14 @@ public class DeptApiImpl implements DeptApi {
}
@Override
public
CommonResult
<
List
<
DeptRespDTO
>>
getDept
s
(
Collection
<
Long
>
ids
)
{
List
<
DeptDO
>
depts
=
deptService
.
getDept
s
(
ids
);
public
CommonResult
<
List
<
DeptRespDTO
>>
getDept
List
(
Collection
<
Long
>
ids
)
{
List
<
DeptDO
>
depts
=
deptService
.
getDept
List
(
ids
);
return
success
(
DeptConvert
.
INSTANCE
.
convertList03
(
depts
));
}
@Override
public
CommonResult
<
Boolean
>
valid
Depts
(
Collection
<
Long
>
ids
)
{
deptService
.
valid
Depts
(
ids
);
public
CommonResult
<
Boolean
>
valid
ateDeptList
(
Collection
<
Long
>
ids
)
{
deptService
.
valid
ateDeptList
(
ids
);
return
success
(
true
);
}
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java
浏览文件 @
7f6d64e9
...
...
@@ -58,7 +58,7 @@ public class DeptController {
@ApiOperation
(
"获取部门列表"
)
@PreAuthorize
(
"@ss.hasPermission('system:dept:query')"
)
public
CommonResult
<
List
<
DeptRespVO
>>
listDepts
(
DeptListReqVO
reqVO
)
{
List
<
DeptDO
>
list
=
deptService
.
get
SimpleDepts
(
reqVO
);
List
<
DeptDO
>
list
=
deptService
.
get
DeptList
(
reqVO
);
list
.
sort
(
Comparator
.
comparing
(
DeptDO:
:
getSort
));
return
success
(
DeptConvert
.
INSTANCE
.
convertList
(
list
));
}
...
...
@@ -69,7 +69,7 @@ public class DeptController {
// 获得部门列表,只要开启状态的
DeptListReqVO
reqVO
=
new
DeptListReqVO
();
reqVO
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
());
List
<
DeptDO
>
list
=
deptService
.
get
SimpleDepts
(
reqVO
);
List
<
DeptDO
>
list
=
deptService
.
get
DeptList
(
reqVO
);
// 排序后,返回给前端
list
.
sort
(
Comparator
.
comparing
(
DeptDO:
:
getSort
));
return
success
(
DeptConvert
.
INSTANCE
.
convertList02
(
list
));
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java
浏览文件 @
7f6d64e9
...
...
@@ -52,7 +52,7 @@ public interface DeptService {
* @param reqVO 筛选条件请求 VO
* @return 部门列表
*/
List
<
DeptDO
>
get
SimpleDepts
(
DeptListReqVO
reqVO
);
List
<
DeptDO
>
get
DeptList
(
DeptListReqVO
reqVO
);
/**
* 获得所有子部门,从缓存中
...
...
@@ -61,7 +61,7 @@ public interface DeptService {
* @param recursive 是否递归获取所有
* @return 子部门列表
*/
List
<
DeptDO
>
getDept
s
ByParentIdFromCache
(
Long
parentId
,
boolean
recursive
);
List
<
DeptDO
>
getDept
List
ByParentIdFromCache
(
Long
parentId
,
boolean
recursive
);
/**
* 获得部门信息数组
...
...
@@ -69,7 +69,21 @@ public interface DeptService {
* @param ids 部门编号数组
* @return 部门信息数组
*/
List
<
DeptDO
>
getDepts
(
Collection
<
Long
>
ids
);
List
<
DeptDO
>
getDeptList
(
Collection
<
Long
>
ids
);
/**
* 获得指定编号的部门 Map
*
* @param ids 部门编号数组
* @return 部门 Map
*/
default
Map
<
Long
,
DeptDO
>
getDeptMap
(
Collection
<
Long
>
ids
)
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
return
Collections
.
emptyMap
();
}
List
<
DeptDO
>
list
=
getDeptList
(
ids
);
return
CollectionUtils
.
convertMap
(
list
,
DeptDO:
:
getId
);
}
/**
* 获得部门信息
...
...
@@ -86,27 +100,6 @@ public interface DeptService {
*
* @param ids 角色编号数组
*/
void
valid
Depts
(
Collection
<
Long
>
ids
);
void
valid
ateDeptList
(
Collection
<
Long
>
ids
);
/**
* 获得指定编号的部门列表
*
* @param ids 部门编号数组
* @return 部门列表
*/
List
<
DeptDO
>
getSimpleDepts
(
Collection
<
Long
>
ids
);
/**
* 获得指定编号的部门 Map
*
* @param ids 部门编号数组
* @return 部门 Map
*/
default
Map
<
Long
,
DeptDO
>
getDeptMap
(
Collection
<
Long
>
ids
)
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
return
Collections
.
emptyMap
();
}
List
<
DeptDO
>
list
=
getSimpleDepts
(
ids
);
return
CollectionUtils
.
convertMap
(
list
,
DeptDO:
:
getId
);
}
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
浏览文件 @
7f6d64e9
...
...
@@ -2,8 +2,6 @@ package cn.iocoder.yudao.module.system.service.dept;
import
cn.hutool.core.collection.CollUtil
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.yudao.framework.common.util.collection.CollectionUtils
;
import
cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder
;
import
cn.iocoder.yudao.framework.tenant.core.util.TenantUtils
;
import
cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptCreateReqVO
;
...
...
@@ -19,13 +17,11 @@ import com.google.common.collect.ImmutableMultimap;
import
com.google.common.collect.Multimap
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
...
...
@@ -95,7 +91,7 @@ public class DeptServiceImpl implements DeptService {
if
(
reqVO
.
getParentId
()
==
null
)
{
reqVO
.
setParentId
(
DeptIdEnum
.
ROOT
.
getId
());
}
check
CreateOrUpdate
(
null
,
reqVO
.
getParentId
(),
reqVO
.
getName
());
validateFor
CreateOrUpdate
(
null
,
reqVO
.
getParentId
(),
reqVO
.
getName
());
// 插入部门
DeptDO
dept
=
DeptConvert
.
INSTANCE
.
convert
(
reqVO
);
deptMapper
.
insert
(
dept
);
...
...
@@ -110,7 +106,7 @@ public class DeptServiceImpl implements DeptService {
if
(
reqVO
.
getParentId
()
==
null
)
{
reqVO
.
setParentId
(
DeptIdEnum
.
ROOT
.
getId
());
}
check
CreateOrUpdate
(
reqVO
.
getId
(),
reqVO
.
getParentId
(),
reqVO
.
getName
());
validateFor
CreateOrUpdate
(
reqVO
.
getId
(),
reqVO
.
getParentId
(),
reqVO
.
getName
());
// 更新部门
DeptDO
updateObj
=
DeptConvert
.
INSTANCE
.
convert
(
reqVO
);
deptMapper
.
updateById
(
updateObj
);
...
...
@@ -121,10 +117,10 @@ public class DeptServiceImpl implements DeptService {
@Override
public
void
deleteDept
(
Long
id
)
{
// 校验是否存在
check
DeptExists
(
id
);
validate
DeptExists
(
id
);
// 校验是否有子部门
if
(
deptMapper
.
selectCountByParentId
(
id
)
>
0
)
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_EXITS_CHILDREN
);
throw
exception
(
DEPT_EXITS_CHILDREN
);
}
// 删除部门
deptMapper
.
deleteById
(
id
);
...
...
@@ -133,16 +129,16 @@ public class DeptServiceImpl implements DeptService {
}
@Override
public
List
<
DeptDO
>
get
SimpleDepts
(
DeptListReqVO
reqVO
)
{
public
List
<
DeptDO
>
get
DeptList
(
DeptListReqVO
reqVO
)
{
return
deptMapper
.
selectList
(
reqVO
);
}
@Override
public
List
<
DeptDO
>
getDept
s
ByParentIdFromCache
(
Long
parentId
,
boolean
recursive
)
{
public
List
<
DeptDO
>
getDept
List
ByParentIdFromCache
(
Long
parentId
,
boolean
recursive
)
{
if
(
parentId
==
null
)
{
return
Collections
.
emptyList
();
}
List
<
DeptDO
>
result
=
new
ArrayList
<>();
// TODO 芋艿:待优化,新增缓存,避免每次遍历的计算
List
<
DeptDO
>
result
=
new
ArrayList
<>();
// 递归,简单粗暴
this
.
getDeptsByParentIdFromCache
(
result
,
parentId
,
recursive
?
Integer
.
MAX_VALUE
:
1
,
// 如果递归获取,则无限;否则,只递归 1 次
...
...
@@ -182,65 +178,65 @@ public class DeptServiceImpl implements DeptService {
recursiveCount
-
1
,
parentDeptMap
));
}
private
void
check
CreateOrUpdate
(
Long
id
,
Long
parentId
,
String
name
)
{
private
void
validateFor
CreateOrUpdate
(
Long
id
,
Long
parentId
,
String
name
)
{
// 校验自己存在
check
DeptExists
(
id
);
validate
DeptExists
(
id
);
// 校验父部门的有效性
check
ParentDeptEnable
(
id
,
parentId
);
validate
ParentDeptEnable
(
id
,
parentId
);
// 校验部门名的唯一性
check
DeptNameUnique
(
id
,
parentId
,
name
);
validate
DeptNameUnique
(
id
,
parentId
,
name
);
}
private
void
check
ParentDeptEnable
(
Long
id
,
Long
parentId
)
{
private
void
validate
ParentDeptEnable
(
Long
id
,
Long
parentId
)
{
if
(
parentId
==
null
||
DeptIdEnum
.
ROOT
.
getId
().
equals
(
parentId
))
{
return
;
}
// 不能设置自己为父部门
if
(
parentId
.
equals
(
id
))
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_PARENT_ERROR
);
throw
exception
(
DEPT_PARENT_ERROR
);
}
// 父岗位不存在
DeptDO
dept
=
deptMapper
.
selectById
(
parentId
);
if
(
dept
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_PARENT_NOT_EXITS
);
throw
exception
(
DEPT_PARENT_NOT_EXITS
);
}
// 父部门被禁用
if
(!
CommonStatusEnum
.
ENABLE
.
getStatus
().
equals
(
dept
.
getStatus
()))
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_NOT_ENABLE
);
throw
exception
(
DEPT_NOT_ENABLE
);
}
// 父部门不能是原来的子部门
List
<
DeptDO
>
children
=
this
.
getDept
s
ByParentIdFromCache
(
id
,
true
);
List
<
DeptDO
>
children
=
this
.
getDept
List
ByParentIdFromCache
(
id
,
true
);
if
(
children
.
stream
().
anyMatch
(
dept1
->
dept1
.
getId
().
equals
(
parentId
)))
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_PARENT_IS_CHILD
);
throw
exception
(
DEPT_PARENT_IS_CHILD
);
}
}
private
void
check
DeptExists
(
Long
id
)
{
private
void
validate
DeptExists
(
Long
id
)
{
if
(
id
==
null
)
{
return
;
}
DeptDO
dept
=
deptMapper
.
selectById
(
id
);
if
(
dept
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_NOT_FOUND
);
throw
exception
(
DEPT_NOT_FOUND
);
}
}
private
void
check
DeptNameUnique
(
Long
id
,
Long
parentId
,
String
name
)
{
private
void
validate
DeptNameUnique
(
Long
id
,
Long
parentId
,
String
name
)
{
DeptDO
menu
=
deptMapper
.
selectByParentIdAndName
(
parentId
,
name
);
if
(
menu
==
null
)
{
return
;
}
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
if
(
id
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_NAME_DUPLICATE
);
throw
exception
(
DEPT_NAME_DUPLICATE
);
}
if
(!
menu
.
getId
().
equals
(
id
))
{
throw
ServiceExceptionUtil
.
exception
(
DEPT_NAME_DUPLICATE
);
throw
exception
(
DEPT_NAME_DUPLICATE
);
}
}
@Override
public
List
<
DeptDO
>
getDept
s
(
Collection
<
Long
>
ids
)
{
public
List
<
DeptDO
>
getDept
List
(
Collection
<
Long
>
ids
)
{
return
deptMapper
.
selectBatchIds
(
ids
);
}
...
...
@@ -250,13 +246,12 @@ public class DeptServiceImpl implements DeptService {
}
@Override
public
void
valid
Depts
(
Collection
<
Long
>
ids
)
{
public
void
valid
ateDeptList
(
Collection
<
Long
>
ids
)
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
return
;
}
// 获得科室信息
List
<
DeptDO
>
depts
=
deptMapper
.
selectBatchIds
(
ids
);
Map
<
Long
,
DeptDO
>
deptMap
=
CollectionUtils
.
convertMap
(
depts
,
DeptDO:
:
getId
);
Map
<
Long
,
DeptDO
>
deptMap
=
getDeptMap
(
ids
);
// 校验
ids
.
forEach
(
id
->
{
DeptDO
dept
=
deptMap
.
get
(
id
);
...
...
@@ -269,9 +264,4 @@ public class DeptServiceImpl implements DeptService {
});
}
@Override
public
List
<
DeptDO
>
getSimpleDepts
(
Collection
<
Long
>
ids
)
{
return
deptMapper
.
selectBatchIds
(
ids
);
}
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java
浏览文件 @
7f6d64e9
...
...
@@ -418,7 +418,7 @@ public class PermissionServiceImpl implements PermissionService {
}
// 情况四,DEPT_DEPT_AND_CHILD
if
(
Objects
.
equals
(
role
.
getDataScope
(),
DataScopeEnum
.
DEPT_AND_CHILD
.
getScope
()))
{
List
<
DeptDO
>
depts
=
deptService
.
getDept
s
ByParentIdFromCache
(
userDeptIdCache
.
get
(),
true
);
List
<
DeptDO
>
depts
=
deptService
.
getDept
List
ByParentIdFromCache
(
userDeptIdCache
.
get
(),
true
);
CollUtil
.
addAll
(
result
.
getDeptIds
(),
CollectionUtils
.
convertList
(
depts
,
DeptDO:
:
getId
));
// 添加本身部门编号
CollUtil
.
addAll
(
result
.
getDeptIds
(),
userDeptIdCache
.
get
());
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
浏览文件 @
7f6d64e9
...
...
@@ -298,7 +298,7 @@ public class AdminUserServiceImpl implements AdminUserService {
if
(
deptId
==
null
)
{
return
Collections
.
emptySet
();
}
Set
<
Long
>
deptIds
=
convertSet
(
deptService
.
getDept
s
ByParentIdFromCache
(
Set
<
Long
>
deptIds
=
convertSet
(
deptService
.
getDept
List
ByParentIdFromCache
(
deptId
,
true
),
DeptDO:
:
getId
);
deptIds
.
add
(
deptId
);
// 包括自身
return
deptIds
;
...
...
@@ -316,7 +316,7 @@ public class AdminUserServiceImpl implements AdminUserService {
// 校验邮箱唯一
checkEmailUnique
(
id
,
email
);
// 校验部门处于开启状态
deptService
.
valid
Depts
(
CollectionUtils
.
singleton
(
deptId
));
deptService
.
valid
ateDeptList
(
CollectionUtils
.
singleton
(
deptId
));
// 校验岗位处于开启状态
postService
.
validPosts
(
postIds
);
}
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceTest.java
→
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptService
Impl
Test.java
浏览文件 @
7f6d64e9
差异被折叠。
点击展开。
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java
浏览文件 @
7f6d64e9
...
...
@@ -509,7 +509,7 @@ public class PermissionServiceTest extends BaseDbUnitTest {
when
(
userService
.
getUser
(
eq
(
1L
))).
thenReturn
(
new
AdminUserDO
().
setDeptId
(
3L
),
null
,
null
);
// 最后返回 null 的目的,看看会不会重复调用
// mock 方法(部门)
DeptDO
deptDO
=
randomPojo
(
DeptDO
.
class
);
when
(
deptService
.
getDept
s
ByParentIdFromCache
(
eq
(
3L
),
eq
(
true
)))
when
(
deptService
.
getDept
List
ByParentIdFromCache
(
eq
(
3L
),
eq
(
true
)))
.
thenReturn
(
singletonList
(
deptDO
));
// 调用
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java
浏览文件 @
7f6d64e9
...
...
@@ -300,7 +300,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
reqVO
.
setDeptId
(
1L
);
// 其中,1L 是 2L 的父部门
// mock 方法
List
<
DeptDO
>
deptList
=
newArrayList
(
randomPojo
(
DeptDO
.
class
,
o
->
o
.
setId
(
2L
)));
when
(
deptService
.
getDept
s
ByParentIdFromCache
(
eq
(
reqVO
.
getDeptId
()),
eq
(
true
))).
thenReturn
(
deptList
);
when
(
deptService
.
getDept
List
ByParentIdFromCache
(
eq
(
reqVO
.
getDeptId
()),
eq
(
true
))).
thenReturn
(
deptList
);
// 调用
PageResult
<
AdminUserDO
>
pageResult
=
userService
.
getUserPage
(
reqVO
);
...
...
@@ -324,7 +324,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
reqVO
.
setDeptId
(
1L
);
// 其中,1L 是 2L 的父部门
// mock 方法
List
<
DeptDO
>
deptList
=
newArrayList
(
randomPojo
(
DeptDO
.
class
,
o
->
o
.
setId
(
2L
)));
when
(
deptService
.
getDept
s
ByParentIdFromCache
(
eq
(
reqVO
.
getDeptId
()),
eq
(
true
))).
thenReturn
(
deptList
);
when
(
deptService
.
getDept
List
ByParentIdFromCache
(
eq
(
reqVO
.
getDeptId
()),
eq
(
true
))).
thenReturn
(
deptList
);
// 调用
List
<
AdminUserDO
>
list
=
userService
.
getUsers
(
reqVO
);
...
...
@@ -368,7 +368,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
UserImportExcelVO
importUser
=
randomPojo
(
UserImportExcelVO
.
class
,
o
->
{
});
// mock 方法,模拟失败
doThrow
(
new
ServiceException
(
DEPT_NOT_FOUND
)).
when
(
deptService
).
valid
Depts
(
any
());
doThrow
(
new
ServiceException
(
DEPT_NOT_FOUND
)).
when
(
deptService
).
valid
ateDeptList
(
any
());
// 调用
UserImportRespVO
respVO
=
userService
.
importUsers
(
newArrayList
(
importUser
),
true
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论