Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
6d770bba
提交
6d770bba
authored
1月 31, 2023
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善 PostServiceImpl 单元测试
上级
7f6d64e9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
59 行增加
和
59 行删除
+59
-59
BpmTaskAssignRuleServiceImpl.java
.../bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
+1
-1
PostApi.java
...java/cn/iocoder/yudao/module/system/api/dept/PostApi.java
+1
-1
ErrorCodeConstants.java
...iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+1
-1
PostApiImpl.java
.../cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java
+2
-2
PostController.java
...o/module/system/controller/admin/dept/PostController.java
+2
-2
OAuth2UserController.java
.../system/controller/admin/oauth2/OAuth2UserController.java
+1
-1
UserProfileController.java
...e/system/controller/admin/user/UserProfileController.java
+1
-1
PostService.java
...iocoder/yudao/module/system/service/dept/PostService.java
+5
-5
PostServiceImpl.java
...der/yudao/module/system/service/dept/PostServiceImpl.java
+39
-39
AdminUserServiceImpl.java
...udao/module/system/service/user/AdminUserServiceImpl.java
+1
-1
DeptServiceImplTest.java
...yudao/module/system/service/dept/DeptServiceImplTest.java
+3
-3
PostServiceImplTest.java
...yudao/module/system/service/dept/PostServiceImplTest.java
+0
-0
AdminUserServiceImplTest.java
.../module/system/service/user/AdminUserServiceImplTest.java
+2
-2
没有找到文件。
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
浏览文件 @
6d770bba
...
@@ -218,7 +218,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
...
@@ -218,7 +218,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
BpmTaskAssignRuleTypeEnum
.
DEPT_LEADER
.
getType
()))
{
BpmTaskAssignRuleTypeEnum
.
DEPT_LEADER
.
getType
()))
{
deptApi
.
validateDeptList
(
options
);
deptApi
.
validateDeptList
(
options
);
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
POST
.
getType
()))
{
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
POST
.
getType
()))
{
postApi
.
validPost
s
(
options
);
postApi
.
validPost
List
(
options
);
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
USER
.
getType
()))
{
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
USER
.
getType
()))
{
adminUserApi
.
validUsers
(
options
);
adminUserApi
.
validUsers
(
options
);
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
USER_GROUP
.
getType
()))
{
}
else
if
(
Objects
.
equals
(
type
,
BpmTaskAssignRuleTypeEnum
.
USER_GROUP
.
getType
()))
{
...
...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java
浏览文件 @
6d770bba
...
@@ -20,6 +20,6 @@ public interface PostApi {
...
@@ -20,6 +20,6 @@ public interface PostApi {
@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
>
validPost
s
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
CommonResult
<
Boolean
>
validPost
List
(
@RequestParam
(
"ids"
)
Collection
<
Long
>
ids
);
}
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
浏览文件 @
6d770bba
...
@@ -50,7 +50,7 @@ public interface ErrorCodeConstants {
...
@@ -50,7 +50,7 @@ public interface ErrorCodeConstants {
ErrorCode
DEPT_EXITS_CHILDREN
=
new
ErrorCode
(
1002004003
,
"存在子部门,无法删除"
);
ErrorCode
DEPT_EXITS_CHILDREN
=
new
ErrorCode
(
1002004003
,
"存在子部门,无法删除"
);
ErrorCode
DEPT_PARENT_ERROR
=
new
ErrorCode
(
1002004004
,
"不能设置自己为父部门"
);
ErrorCode
DEPT_PARENT_ERROR
=
new
ErrorCode
(
1002004004
,
"不能设置自己为父部门"
);
ErrorCode
DEPT_EXISTS_USER
=
new
ErrorCode
(
1002004005
,
"部门中存在员工,无法删除"
);
ErrorCode
DEPT_EXISTS_USER
=
new
ErrorCode
(
1002004005
,
"部门中存在员工,无法删除"
);
ErrorCode
DEPT_NOT_ENABLE
=
new
ErrorCode
(
1002004006
,
"部门不处于开启状态,不允许选择"
);
ErrorCode
DEPT_NOT_ENABLE
=
new
ErrorCode
(
1002004006
,
"部门
({})
不处于开启状态,不允许选择"
);
ErrorCode
DEPT_PARENT_IS_CHILD
=
new
ErrorCode
(
1002004007
,
"不能设置自己的子部门为父部门"
);
ErrorCode
DEPT_PARENT_IS_CHILD
=
new
ErrorCode
(
1002004007
,
"不能设置自己的子部门为父部门"
);
// ========== 岗位模块 1002005000 ==========
// ========== 岗位模块 1002005000 ==========
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java
浏览文件 @
6d770bba
...
@@ -22,8 +22,8 @@ public class PostApiImpl implements PostApi {
...
@@ -22,8 +22,8 @@ public class PostApiImpl implements PostApi {
private
PostService
postService
;
private
PostService
postService
;
@Override
@Override
public
CommonResult
<
Boolean
>
validPost
s
(
Collection
<
Long
>
ids
)
{
public
CommonResult
<
Boolean
>
validPost
List
(
Collection
<
Long
>
ids
)
{
postService
.
valid
Posts
(
ids
);
postService
.
valid
atePostList
(
ids
);
return
success
(
true
);
return
success
(
true
);
}
}
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/PostController.java
浏览文件 @
6d770bba
...
@@ -72,7 +72,7 @@ public class PostController {
...
@@ -72,7 +72,7 @@ public class PostController {
@ApiOperation
(
value
=
"获取岗位精简信息列表"
,
notes
=
"只包含被开启的岗位,主要用于前端的下拉选项"
)
@ApiOperation
(
value
=
"获取岗位精简信息列表"
,
notes
=
"只包含被开启的岗位,主要用于前端的下拉选项"
)
public
CommonResult
<
List
<
PostSimpleRespVO
>>
getSimplePosts
()
{
public
CommonResult
<
List
<
PostSimpleRespVO
>>
getSimplePosts
()
{
// 获得岗位列表,只要开启状态的
// 获得岗位列表,只要开启状态的
List
<
PostDO
>
list
=
postService
.
getPost
s
(
null
,
Collections
.
singleton
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
List
<
PostDO
>
list
=
postService
.
getPost
List
(
null
,
Collections
.
singleton
(
CommonStatusEnum
.
ENABLE
.
getStatus
()));
// 排序后,返回给前端
// 排序后,返回给前端
list
.
sort
(
Comparator
.
comparing
(
PostDO:
:
getSort
));
list
.
sort
(
Comparator
.
comparing
(
PostDO:
:
getSort
));
return
success
(
PostConvert
.
INSTANCE
.
convertList02
(
list
));
return
success
(
PostConvert
.
INSTANCE
.
convertList02
(
list
));
...
@@ -90,7 +90,7 @@ public class PostController {
...
@@ -90,7 +90,7 @@ public class PostController {
@PreAuthorize
(
"@ss.hasPermission('system:post:export')"
)
@PreAuthorize
(
"@ss.hasPermission('system:post:export')"
)
@OperateLog
(
type
=
EXPORT
)
@OperateLog
(
type
=
EXPORT
)
public
void
export
(
HttpServletResponse
response
,
@Validated
PostExportReqVO
reqVO
)
throws
IOException
{
public
void
export
(
HttpServletResponse
response
,
@Validated
PostExportReqVO
reqVO
)
throws
IOException
{
List
<
PostDO
>
posts
=
postService
.
getPost
s
(
reqVO
);
List
<
PostDO
>
posts
=
postService
.
getPost
List
(
reqVO
);
List
<
PostExcelVO
>
data
=
PostConvert
.
INSTANCE
.
convertList03
(
posts
);
List
<
PostExcelVO
>
data
=
PostConvert
.
INSTANCE
.
convertList03
(
posts
);
// 输出
// 输出
ExcelUtils
.
write
(
response
,
"岗位数据.xls"
,
"岗位列表"
,
PostExcelVO
.
class
,
data
);
ExcelUtils
.
write
(
response
,
"岗位数据.xls"
,
"岗位列表"
,
PostExcelVO
.
class
,
data
);
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2UserController.java
浏览文件 @
6d770bba
...
@@ -61,7 +61,7 @@ public class OAuth2UserController {
...
@@ -61,7 +61,7 @@ public class OAuth2UserController {
}
}
// 获得岗位信息
// 获得岗位信息
if
(
CollUtil
.
isNotEmpty
(
user
.
getPostIds
()))
{
if
(
CollUtil
.
isNotEmpty
(
user
.
getPostIds
()))
{
List
<
PostDO
>
posts
=
postService
.
getPost
s
(
user
.
getPostIds
());
List
<
PostDO
>
posts
=
postService
.
getPost
List
(
user
.
getPostIds
());
resp
.
setPosts
(
OAuth2UserConvert
.
INSTANCE
.
convertList
(
posts
));
resp
.
setPosts
(
OAuth2UserConvert
.
INSTANCE
.
convertList
(
posts
));
}
}
return
success
(
resp
);
return
success
(
resp
);
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java
浏览文件 @
6d770bba
...
@@ -72,7 +72,7 @@ public class UserProfileController {
...
@@ -72,7 +72,7 @@ public class UserProfileController {
}
}
// 获得岗位信息
// 获得岗位信息
if
(
CollUtil
.
isNotEmpty
(
user
.
getPostIds
()))
{
if
(
CollUtil
.
isNotEmpty
(
user
.
getPostIds
()))
{
List
<
PostDO
>
posts
=
postService
.
getPost
s
(
user
.
getPostIds
());
List
<
PostDO
>
posts
=
postService
.
getPost
List
(
user
.
getPostIds
());
resp
.
setPosts
(
UserConvert
.
INSTANCE
.
convertList02
(
posts
));
resp
.
setPosts
(
UserConvert
.
INSTANCE
.
convertList02
(
posts
));
}
}
// 获得社交用户信息
// 获得社交用户信息
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/PostService.java
浏览文件 @
6d770bba
...
@@ -49,8 +49,8 @@ public interface PostService {
...
@@ -49,8 +49,8 @@ public interface PostService {
* @param ids 岗位编号数组。如果为空,不进行筛选
* @param ids 岗位编号数组。如果为空,不进行筛选
* @return 部门列表
* @return 部门列表
*/
*/
default
List
<
PostDO
>
getPost
s
(
@Nullable
Collection
<
Long
>
ids
)
{
default
List
<
PostDO
>
getPost
List
(
@Nullable
Collection
<
Long
>
ids
)
{
return
getPost
s
(
ids
,
asSet
(
CommonStatusEnum
.
ENABLE
.
getStatus
(),
CommonStatusEnum
.
DISABLE
.
getStatus
()));
return
getPost
List
(
ids
,
asSet
(
CommonStatusEnum
.
ENABLE
.
getStatus
(),
CommonStatusEnum
.
DISABLE
.
getStatus
()));
}
}
/**
/**
...
@@ -60,7 +60,7 @@ public interface PostService {
...
@@ -60,7 +60,7 @@ public interface PostService {
* @param statuses 状态数组。如果为空,不进行筛选
* @param statuses 状态数组。如果为空,不进行筛选
* @return 部门列表
* @return 部门列表
*/
*/
List
<
PostDO
>
getPost
s
(
@Nullable
Collection
<
Long
>
ids
,
@Nullable
Collection
<
Integer
>
statuses
);
List
<
PostDO
>
getPost
List
(
@Nullable
Collection
<
Long
>
ids
,
@Nullable
Collection
<
Integer
>
statuses
);
/**
/**
* 获得岗位分页列表
* 获得岗位分页列表
...
@@ -76,7 +76,7 @@ public interface PostService {
...
@@ -76,7 +76,7 @@ public interface PostService {
* @param reqVO 查询条件
* @param reqVO 查询条件
* @return 部门列表
* @return 部门列表
*/
*/
List
<
PostDO
>
getPost
s
(
PostExportReqVO
reqVO
);
List
<
PostDO
>
getPost
List
(
PostExportReqVO
reqVO
);
/**
/**
* 获得岗位信息
* 获得岗位信息
...
@@ -93,6 +93,6 @@ public interface PostService {
...
@@ -93,6 +93,6 @@ public interface PostService {
*
*
* @param ids 岗位编号数组
* @param ids 岗位编号数组
*/
*/
void
valid
Posts
(
Collection
<
Long
>
ids
);
void
valid
atePostList
(
Collection
<
Long
>
ids
);
}
}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImpl.java
浏览文件 @
6d770bba
...
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.service.dept;
...
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.service.dept;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostCreateReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostCreateReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO
;
...
@@ -38,7 +37,8 @@ public class PostServiceImpl implements PostService {
...
@@ -38,7 +37,8 @@ public class PostServiceImpl implements PostService {
@Override
@Override
public
Long
createPost
(
PostCreateReqVO
reqVO
)
{
public
Long
createPost
(
PostCreateReqVO
reqVO
)
{
// 校验正确性
// 校验正确性
this
.
checkCreateOrUpdate
(
null
,
reqVO
.
getName
(),
reqVO
.
getCode
());
validatePostForCreateOrUpdate
(
null
,
reqVO
.
getName
(),
reqVO
.
getCode
());
// 插入岗位
// 插入岗位
PostDO
post
=
PostConvert
.
INSTANCE
.
convert
(
reqVO
);
PostDO
post
=
PostConvert
.
INSTANCE
.
convert
(
reqVO
);
postMapper
.
insert
(
post
);
postMapper
.
insert
(
post
);
...
@@ -48,7 +48,8 @@ public class PostServiceImpl implements PostService {
...
@@ -48,7 +48,8 @@ public class PostServiceImpl implements PostService {
@Override
@Override
public
void
updatePost
(
PostUpdateReqVO
reqVO
)
{
public
void
updatePost
(
PostUpdateReqVO
reqVO
)
{
// 校验正确性
// 校验正确性
this
.
checkCreateOrUpdate
(
reqVO
.
getId
(),
reqVO
.
getName
(),
reqVO
.
getCode
());
validatePostForCreateOrUpdate
(
reqVO
.
getId
(),
reqVO
.
getName
(),
reqVO
.
getCode
());
// 更新岗位
// 更新岗位
PostDO
updateObj
=
PostConvert
.
INSTANCE
.
convert
(
reqVO
);
PostDO
updateObj
=
PostConvert
.
INSTANCE
.
convert
(
reqVO
);
postMapper
.
updateById
(
updateObj
);
postMapper
.
updateById
(
updateObj
);
...
@@ -57,80 +58,79 @@ public class PostServiceImpl implements PostService {
...
@@ -57,80 +58,79 @@ public class PostServiceImpl implements PostService {
@Override
@Override
public
void
deletePost
(
Long
id
)
{
public
void
deletePost
(
Long
id
)
{
// 校验是否存在
// 校验是否存在
this
.
check
PostExists
(
id
);
validate
PostExists
(
id
);
// 删除部门
// 删除部门
postMapper
.
deleteById
(
id
);
postMapper
.
deleteById
(
id
);
}
}
@Override
private
void
validatePostForCreateOrUpdate
(
Long
id
,
String
name
,
String
code
)
{
public
List
<
PostDO
>
getPosts
(
Collection
<
Long
>
ids
,
Collection
<
Integer
>
statuses
)
{
return
postMapper
.
selectList
(
ids
,
statuses
);
}
@Override
public
PageResult
<
PostDO
>
getPostPage
(
PostPageReqVO
reqVO
)
{
return
postMapper
.
selectPage
(
reqVO
);
}
@Override
public
List
<
PostDO
>
getPosts
(
PostExportReqVO
reqVO
)
{
return
postMapper
.
selectList
(
reqVO
);
}
@Override
public
PostDO
getPost
(
Long
id
)
{
return
postMapper
.
selectById
(
id
);
}
private
void
checkCreateOrUpdate
(
Long
id
,
String
name
,
String
code
)
{
// 校验自己存在
// 校验自己存在
check
PostExists
(
id
);
validate
PostExists
(
id
);
// 校验岗位名的唯一性
// 校验岗位名的唯一性
check
PostNameUnique
(
id
,
name
);
validate
PostNameUnique
(
id
,
name
);
// 校验岗位编码的唯一性
// 校验岗位编码的唯一性
check
PostCodeUnique
(
id
,
code
);
validate
PostCodeUnique
(
id
,
code
);
}
}
private
void
check
PostNameUnique
(
Long
id
,
String
name
)
{
private
void
validate
PostNameUnique
(
Long
id
,
String
name
)
{
PostDO
post
=
postMapper
.
selectByName
(
name
);
PostDO
post
=
postMapper
.
selectByName
(
name
);
if
(
post
==
null
)
{
if
(
post
==
null
)
{
return
;
return
;
}
}
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
POST_NAME_DUPLICATE
);
throw
exception
(
POST_NAME_DUPLICATE
);
}
}
if
(!
post
.
getId
().
equals
(
id
))
{
if
(!
post
.
getId
().
equals
(
id
))
{
throw
ServiceExceptionUtil
.
exception
(
POST_NAME_DUPLICATE
);
throw
exception
(
POST_NAME_DUPLICATE
);
}
}
}
}
private
void
check
PostCodeUnique
(
Long
id
,
String
code
)
{
private
void
validate
PostCodeUnique
(
Long
id
,
String
code
)
{
PostDO
post
=
postMapper
.
selectByCode
(
code
);
PostDO
post
=
postMapper
.
selectByCode
(
code
);
if
(
post
==
null
)
{
if
(
post
==
null
)
{
return
;
return
;
}
}
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
// 如果 id 为空,说明不用比较是否为相同 id 的岗位
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
POST_CODE_DUPLICATE
);
throw
exception
(
POST_CODE_DUPLICATE
);
}
}
if
(!
post
.
getId
().
equals
(
id
))
{
if
(!
post
.
getId
().
equals
(
id
))
{
throw
ServiceExceptionUtil
.
exception
(
POST_CODE_DUPLICATE
);
throw
exception
(
POST_CODE_DUPLICATE
);
}
}
}
}
private
void
check
PostExists
(
Long
id
)
{
private
void
validate
PostExists
(
Long
id
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
return
;
return
;
}
}
PostDO
post
=
postMapper
.
selectById
(
id
);
if
(
postMapper
.
selectById
(
id
)
==
null
)
{
if
(
post
==
null
)
{
throw
exception
(
POST_NOT_FOUND
);
throw
ServiceExceptionUtil
.
exception
(
POST_NOT_FOUND
);
}
}
}
}
@Override
@Override
public
void
validPosts
(
Collection
<
Long
>
ids
)
{
public
List
<
PostDO
>
getPostList
(
Collection
<
Long
>
ids
,
Collection
<
Integer
>
statuses
)
{
return
postMapper
.
selectList
(
ids
,
statuses
);
}
@Override
public
PageResult
<
PostDO
>
getPostPage
(
PostPageReqVO
reqVO
)
{
return
postMapper
.
selectPage
(
reqVO
);
}
@Override
public
List
<
PostDO
>
getPostList
(
PostExportReqVO
reqVO
)
{
return
postMapper
.
selectList
(
reqVO
);
}
@Override
public
PostDO
getPost
(
Long
id
)
{
return
postMapper
.
selectById
(
id
);
}
@Override
public
void
validatePostList
(
Collection
<
Long
>
ids
)
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
if
(
CollUtil
.
isEmpty
(
ids
))
{
return
;
return
;
}
}
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
浏览文件 @
6d770bba
...
@@ -318,7 +318,7 @@ public class AdminUserServiceImpl implements AdminUserService {
...
@@ -318,7 +318,7 @@ public class AdminUserServiceImpl implements AdminUserService {
// 校验部门处于开启状态
// 校验部门处于开启状态
deptService
.
validateDeptList
(
CollectionUtils
.
singleton
(
deptId
));
deptService
.
validateDeptList
(
CollectionUtils
.
singleton
(
deptId
));
// 校验岗位处于开启状态
// 校验岗位处于开启状态
postService
.
valid
Posts
(
postIds
);
postService
.
valid
atePostList
(
postIds
);
}
}
@VisibleForTesting
@VisibleForTesting
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java
浏览文件 @
6d770bba
...
@@ -187,7 +187,7 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
...
@@ -187,7 +187,7 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
public
void
testValidateDept_parentNotExitsForCreate
()
{
public
void
testValidateDept_parentNotExitsForCreate
()
{
// 准备参数
// 准备参数
DeptCreateReqVO
reqVO
=
randomPojo
(
DeptCreateReqVO
.
class
,
DeptCreateReqVO
reqVO
=
randomPojo
(
DeptCreateReqVO
.
class
,
o
->
o
.
setStatus
(
randomCommonStatus
()));
o
->
o
.
setStatus
(
randomCommonStatus
()));
// 调用,并断言异常
// 调用,并断言异常
assertServiceException
(()
->
deptService
.
createDept
(
reqVO
),
DEPT_PARENT_NOT_EXITS
);
assertServiceException
(()
->
deptService
.
createDept
(
reqVO
),
DEPT_PARENT_NOT_EXITS
);
...
@@ -203,7 +203,7 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
...
@@ -203,7 +203,7 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
}
}
@Test
@Test
public
void
testValidateDept_exitsChildrenForDelete
()
{
public
void
testValidateDept_exitsChildrenForDelete
()
{
// mock 数据
// mock 数据
DeptDO
parentDept
=
randomPojo
(
DeptDO
.
class
,
o
->
o
.
setStatus
(
randomCommonStatus
()));
DeptDO
parentDept
=
randomPojo
(
DeptDO
.
class
,
o
->
o
.
setStatus
(
randomCommonStatus
()));
deptMapper
.
insert
(
parentDept
);
// @Sql: 先插入出一条存在的数据
deptMapper
.
insert
(
parentDept
);
// @Sql: 先插入出一条存在的数据
...
@@ -337,7 +337,7 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
...
@@ -337,7 +337,7 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
List
<
Long
>
ids
=
singletonList
(
deptDO
.
getId
());
List
<
Long
>
ids
=
singletonList
(
deptDO
.
getId
());
// 调用, 并断言异常
// 调用, 并断言异常
assertServiceException
(()
->
deptService
.
validateDeptList
(
ids
),
DEPT_NOT_ENABLE
);
assertServiceException
(()
->
deptService
.
validateDeptList
(
ids
),
DEPT_NOT_ENABLE
,
deptDO
.
getName
()
);
}
}
@SafeVarargs
@SafeVarargs
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceTest.java
→
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostService
Impl
Test.java
浏览文件 @
6d770bba
差异被折叠。
点击展开。
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java
浏览文件 @
6d770bba
...
@@ -102,7 +102,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
...
@@ -102,7 +102,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
o
.
setId
(
postId
);
o
.
setId
(
postId
);
o
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
());
o
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
());
}));
}));
when
(
postService
.
getPost
s
(
eq
(
reqVO
.
getPostIds
()),
isNull
())).
thenReturn
(
posts
);
when
(
postService
.
getPost
List
(
eq
(
reqVO
.
getPostIds
()),
isNull
())).
thenReturn
(
posts
);
// mock passwordEncoder 的方法
// mock passwordEncoder 的方法
when
(
passwordEncoder
.
encode
(
eq
(
reqVO
.
getPassword
()))).
thenReturn
(
"yudaoyuanma"
);
when
(
passwordEncoder
.
encode
(
eq
(
reqVO
.
getPassword
()))).
thenReturn
(
"yudaoyuanma"
);
...
@@ -160,7 +160,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
...
@@ -160,7 +160,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
o
.
setId
(
postId
);
o
.
setId
(
postId
);
o
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
());
o
.
setStatus
(
CommonStatusEnum
.
ENABLE
.
getStatus
());
}));
}));
when
(
postService
.
getPost
s
(
eq
(
reqVO
.
getPostIds
()),
isNull
())).
thenReturn
(
posts
);
when
(
postService
.
getPost
List
(
eq
(
reqVO
.
getPostIds
()),
isNull
())).
thenReturn
(
posts
);
// 调用
// 调用
userService
.
updateUser
(
reqVO
);
userService
.
updateUser
(
reqVO
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论