Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
0a2fbae9
提交
0a2fbae9
authored
1月 31, 2023
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善 DictTypeServiceImpl 单元测试
上级
30f097ed
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
10 行删除
+12
-10
DictTypeServiceImpl.java
...yudao/module/system/service/dict/DictTypeServiceImpl.java
+12
-10
DictTypeServiceImplTest.java
...o/module/system/service/dict/DictTypeServiceImplTest.java
+0
-0
没有找到文件。
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImpl.java
浏览文件 @
0a2fbae9
...
...
@@ -57,7 +57,8 @@ public class DictTypeServiceImpl implements DictTypeService {
@Override
public
Long
createDictType
(
DictTypeCreateReqVO
reqVO
)
{
// 校验正确性
checkCreateOrUpdate
(
null
,
reqVO
.
getName
(),
reqVO
.
getType
());
validateDictTypeForCreateOrUpdate
(
null
,
reqVO
.
getName
(),
reqVO
.
getType
());
// 插入字典类型
DictTypeDO
dictType
=
DictTypeConvert
.
INSTANCE
.
convert
(
reqVO
)
.
setDeletedTime
(
LocalDateTimeUtils
.
EMPTY
);
// 唯一索引,避免 null 值
...
...
@@ -68,7 +69,8 @@ public class DictTypeServiceImpl implements DictTypeService {
@Override
public
void
updateDictType
(
DictTypeUpdateReqVO
reqVO
)
{
// 校验正确性
checkCreateOrUpdate
(
reqVO
.
getId
(),
reqVO
.
getName
(),
null
);
validateDictTypeForCreateOrUpdate
(
reqVO
.
getId
(),
reqVO
.
getName
(),
null
);
// 更新字典类型
DictTypeDO
updateObj
=
DictTypeConvert
.
INSTANCE
.
convert
(
reqVO
);
dictTypeMapper
.
updateById
(
updateObj
);
...
...
@@ -77,7 +79,7 @@ public class DictTypeServiceImpl implements DictTypeService {
@Override
public
void
deleteDictType
(
Long
id
)
{
// 校验是否存在
DictTypeDO
dictType
=
check
DictTypeExists
(
id
);
DictTypeDO
dictType
=
validate
DictTypeExists
(
id
);
// 校验是否有字典数据
if
(
dictDataService
.
countByDictType
(
dictType
.
getType
())
>
0
)
{
throw
exception
(
DICT_TYPE_HAS_CHILDREN
);
...
...
@@ -91,17 +93,17 @@ public class DictTypeServiceImpl implements DictTypeService {
return
dictTypeMapper
.
selectList
();
}
private
void
check
CreateOrUpdate
(
Long
id
,
String
name
,
String
type
)
{
private
void
validateDictTypeFor
CreateOrUpdate
(
Long
id
,
String
name
,
String
type
)
{
// 校验自己存在
check
DictTypeExists
(
id
);
validate
DictTypeExists
(
id
);
// 校验字典类型的名字的唯一性
check
DictTypeNameUnique
(
id
,
name
);
validate
DictTypeNameUnique
(
id
,
name
);
// 校验字典类型的类型的唯一性
check
DictTypeUnique
(
id
,
type
);
validate
DictTypeUnique
(
id
,
type
);
}
@VisibleForTesting
public
void
check
DictTypeNameUnique
(
Long
id
,
String
name
)
{
void
validate
DictTypeNameUnique
(
Long
id
,
String
name
)
{
DictTypeDO
dictType
=
dictTypeMapper
.
selectByName
(
name
);
if
(
dictType
==
null
)
{
return
;
...
...
@@ -116,7 +118,7 @@ public class DictTypeServiceImpl implements DictTypeService {
}
@VisibleForTesting
public
void
check
DictTypeUnique
(
Long
id
,
String
type
)
{
void
validate
DictTypeUnique
(
Long
id
,
String
type
)
{
if
(
StrUtil
.
isEmpty
(
type
))
{
return
;
}
...
...
@@ -134,7 +136,7 @@ public class DictTypeServiceImpl implements DictTypeService {
}
@VisibleForTesting
public
DictTypeDO
check
DictTypeExists
(
Long
id
)
{
DictTypeDO
validate
DictTypeExists
(
Long
id
)
{
if
(
id
==
null
)
{
return
null
;
}
...
...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceTest.java
→
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeService
Impl
Test.java
浏览文件 @
0a2fbae9
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论