Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
f620bc3f
提交
f620bc3f
authored
2月 03, 2023
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
infra:完善 config 的单元测试
上级
df65b88f
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
70 行增加
和
57 行删除
+70
-57
ConfigController.java
...odule/infra/controller/admin/config/ConfigController.java
+4
-4
ConfigServiceImpl.java
.../yudao/module/infra/service/config/ConfigServiceImpl.java
+14
-14
ConfigServiceTest.java
.../yudao/module/infra/service/config/ConfigServiceTest.java
+41
-29
UserProfileController.java
...e/system/controller/admin/user/UserProfileController.java
+2
-1
MenuServiceImpl.java
...dao/module/system/service/permission/MenuServiceImpl.java
+9
-8
SmsTemplateServiceImpl.java
...dao/module/system/service/sms/SmsTemplateServiceImpl.java
+0
-1
没有找到文件。
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/ConfigController.java
浏览文件 @
f620bc3f
package
cn
.
iocoder
.
yudao
.
module
.
infra
.
controller
.
admin
.
config
;
import
cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.excel.core.util.ExcelUtils
;
...
...
@@ -23,6 +22,7 @@ import javax.validation.Valid;
import
java.io.IOException
;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
operatelog
.
core
.
enums
.
OperateTypeEnum
.
EXPORT
;
...
...
@@ -76,7 +76,7 @@ public class ConfigController {
return
null
;
}
if
(!
config
.
getVisible
())
{
throw
ServiceExceptionUtil
.
exception
(
ErrorCodeConstants
.
CONFIG_GET_VALUE_ERROR_IF_VISIBLE
);
throw
exception
(
ErrorCodeConstants
.
CONFIG_GET_VALUE_ERROR_IF_VISIBLE
);
}
return
success
(
config
.
getValue
());
}
...
...
@@ -93,8 +93,8 @@ public class ConfigController {
@ApiOperation
(
"导出参数配置"
)
@PreAuthorize
(
"@ss.hasPermission('infra:config:export')"
)
@OperateLog
(
type
=
EXPORT
)
public
void
export
Sys
Config
(
@Valid
ConfigExportReqVO
reqVO
,
HttpServletResponse
response
)
throws
IOException
{
public
void
exportConfig
(
@Valid
ConfigExportReqVO
reqVO
,
HttpServletResponse
response
)
throws
IOException
{
List
<
ConfigDO
>
list
=
configService
.
getConfigList
(
reqVO
);
// 拼接数据
List
<
ConfigExcelVO
>
datas
=
ConfigConvert
.
INSTANCE
.
convertList
(
list
);
...
...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImpl.java
浏览文件 @
f620bc3f
...
...
@@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqV
import
cn.iocoder.yudao.module.infra.convert.config.ConfigConvert
;
import
cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO
;
import
cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper
;
import
cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants
;
import
cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum
;
import
com.google.common.annotations.VisibleForTesting
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -20,6 +19,7 @@ import javax.annotation.Resource;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
infra
.
enums
.
ErrorCodeConstants
.*;
/**
* 参数配置 Service 实现类
...
...
@@ -35,7 +35,7 @@ public class ConfigServiceImpl implements ConfigService {
@Override
public
Long
createConfig
(
ConfigCreateReqVO
reqVO
)
{
// 校验正确性
check
CreateOrUpdate
(
null
,
reqVO
.
getKey
());
validateConfigFor
CreateOrUpdate
(
null
,
reqVO
.
getKey
());
// 插入参数配置
ConfigDO
config
=
ConfigConvert
.
INSTANCE
.
convert
(
reqVO
);
config
.
setType
(
ConfigTypeEnum
.
CUSTOM
.
getType
());
...
...
@@ -46,19 +46,19 @@ public class ConfigServiceImpl implements ConfigService {
@Override
public
void
updateConfig
(
ConfigUpdateReqVO
reqVO
)
{
// 校验正确性
check
CreateOrUpdate
(
reqVO
.
getId
(),
null
);
// 不允许更新 key
validateConfigFor
CreateOrUpdate
(
reqVO
.
getId
(),
null
);
// 不允许更新 key
// 更新参数配置
ConfigDO
updateObj
=
ConfigConvert
.
INSTANCE
.
convert
(
reqVO
);
configMapper
.
updateById
(
updateObj
);
;
configMapper
.
updateById
(
updateObj
);
}
@Override
public
void
deleteConfig
(
Long
id
)
{
// 校验配置存在
ConfigDO
config
=
check
ConfigExists
(
id
);
ConfigDO
config
=
validate
ConfigExists
(
id
);
// 内置配置,不允许删除
if
(
ConfigTypeEnum
.
SYSTEM
.
getType
().
equals
(
config
.
getType
()))
{
throw
exception
(
ErrorCodeConstants
.
CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE
);
throw
exception
(
CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE
);
}
// 删除
configMapper
.
deleteById
(
id
);
...
...
@@ -84,39 +84,39 @@ public class ConfigServiceImpl implements ConfigService {
return
configMapper
.
selectList
(
reqVO
);
}
private
void
check
CreateOrUpdate
(
Long
id
,
String
key
)
{
private
void
validateConfigFor
CreateOrUpdate
(
Long
id
,
String
key
)
{
// 校验自己存在
check
ConfigExists
(
id
);
validate
ConfigExists
(
id
);
// 校验参数配置 key 的唯一性
if
(
StrUtil
.
isNotEmpty
(
key
))
{
check
ConfigKeyUnique
(
id
,
key
);
validate
ConfigKeyUnique
(
id
,
key
);
}
}
@VisibleForTesting
public
ConfigDO
check
ConfigExists
(
Long
id
)
{
public
ConfigDO
validate
ConfigExists
(
Long
id
)
{
if
(
id
==
null
)
{
return
null
;
}
ConfigDO
config
=
configMapper
.
selectById
(
id
);
if
(
config
==
null
)
{
throw
exception
(
ErrorCodeConstants
.
CONFIG_NOT_EXISTS
);
throw
exception
(
CONFIG_NOT_EXISTS
);
}
return
config
;
}
@VisibleForTesting
public
void
check
ConfigKeyUnique
(
Long
id
,
String
key
)
{
public
void
validate
ConfigKeyUnique
(
Long
id
,
String
key
)
{
ConfigDO
config
=
configMapper
.
selectByKey
(
key
);
if
(
config
==
null
)
{
return
;
}
// 如果 id 为空,说明不用比较是否为相同 id 的参数配置
if
(
id
==
null
)
{
throw
exception
(
ErrorCodeConstants
.
CONFIG_KEY_DUPLICATE
);
throw
exception
(
CONFIG_KEY_DUPLICATE
);
}
if
(!
config
.
getId
().
equals
(
id
))
{
throw
exception
(
ErrorCodeConstants
.
CONFIG_KEY_DUPLICATE
);
throw
exception
(
CONFIG_KEY_DUPLICATE
);
}
}
...
...
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceTest.java
浏览文件 @
f620bc3f
...
...
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.infra.service.config;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.util.collection.ArrayUtils
;
import
cn.iocoder.yudao.framework.common.util.object.ObjectUtils
;
import
cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest
;
import
cn.iocoder.yudao.framework.test.core.util.RandomUtils
;
import
cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigCreateReqVO
;
...
...
@@ -12,24 +11,22 @@ import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqV
import
cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO
;
import
cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper
;
import
cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.context.annotation.Import
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
static
cn
.
hutool
.
core
.
util
.
RandomUtil
.
randomEle
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
buildLocalDateTime
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
LocalDateTimeUtils
.
buildBetweenTime
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
LocalDateTimeUtils
.
buildTime
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
object
.
ObjectUtils
.
cloneIgnoreId
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
test
.
core
.
util
.
AssertUtils
.
assertPojoEquals
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
test
.
core
.
util
.
AssertUtils
.
assertServiceException
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
test
.
core
.
util
.
RandomUtils
.*;
import
static
cn
.
iocoder
.
yudao
.
module
.
infra
.
enums
.
ErrorCodeConstants
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
@Import
(
ConfigServiceImpl
.
class
)
public
class
ConfigServiceTest
extends
BaseDbUnitTest
{
...
...
@@ -52,7 +49,7 @@ public class ConfigServiceTest extends BaseDbUnitTest {
// 校验记录的属性是否正确
ConfigDO
config
=
configMapper
.
selectById
(
configId
);
assertPojoEquals
(
reqVO
,
config
);
Assertions
.
assertEquals
(
ConfigTypeEnum
.
CUSTOM
.
getType
(),
config
.
getType
());
assertEquals
(
ConfigTypeEnum
.
CUSTOM
.
getType
(),
config
.
getType
());
}
@Test
...
...
@@ -103,40 +100,40 @@ public class ConfigServiceTest extends BaseDbUnitTest {
}
@Test
public
void
test
Check
ConfigExists_success
()
{
public
void
test
Validate
ConfigExists_success
()
{
// mock 数据
ConfigDO
dbConfigDO
=
randomConfigDO
();
configMapper
.
insert
(
dbConfigDO
);
// @Sql: 先插入出一条存在的数据
// 调用成功
configService
.
check
ConfigExists
(
dbConfigDO
.
getId
());
configService
.
validate
ConfigExists
(
dbConfigDO
.
getId
());
}
@Test
public
void
test
Check
ConfigExist_notExists
()
{
assertServiceException
(()
->
configService
.
check
ConfigExists
(
randomLongId
()),
CONFIG_NOT_EXISTS
);
public
void
test
Validate
ConfigExist_notExists
()
{
assertServiceException
(()
->
configService
.
validate
ConfigExists
(
randomLongId
()),
CONFIG_NOT_EXISTS
);
}
@Test
public
void
test
Check
ConfigKeyUnique_success
()
{
public
void
test
Validate
ConfigKeyUnique_success
()
{
// 调用,成功
configService
.
check
ConfigKeyUnique
(
randomLongId
(),
randomString
());
configService
.
validate
ConfigKeyUnique
(
randomLongId
(),
randomString
());
}
@Test
public
void
test
Check
ConfigKeyUnique_keyDuplicateForCreate
()
{
public
void
test
Validate
ConfigKeyUnique_keyDuplicateForCreate
()
{
// 准备参数
String
key
=
randomString
();
// mock 数据
configMapper
.
insert
(
randomConfigDO
(
o
->
o
.
setConfigKey
(
key
)));
// 调用,校验异常
assertServiceException
(()
->
configService
.
check
ConfigKeyUnique
(
null
,
key
),
assertServiceException
(()
->
configService
.
validate
ConfigKeyUnique
(
null
,
key
),
CONFIG_KEY_DUPLICATE
);
}
@Test
public
void
test
Check
ConfigKeyUnique_keyDuplicateForUpdate
()
{
public
void
test
Validate
ConfigKeyUnique_keyDuplicateForUpdate
()
{
// 准备参数
Long
id
=
randomLongId
();
String
key
=
randomString
();
...
...
@@ -144,7 +141,7 @@ public class ConfigServiceTest extends BaseDbUnitTest {
configMapper
.
insert
(
randomConfigDO
(
o
->
o
.
setConfigKey
(
key
)));
// 调用,校验异常
assertServiceException
(()
->
configService
.
check
ConfigKeyUnique
(
id
,
key
),
assertServiceException
(()
->
configService
.
validate
ConfigKeyUnique
(
id
,
key
),
CONFIG_KEY_DUPLICATE
);
}
...
...
@@ -155,23 +152,23 @@ public class ConfigServiceTest extends BaseDbUnitTest {
o
.
setName
(
"芋艿"
);
o
.
setConfigKey
(
"yunai"
);
o
.
setType
(
ConfigTypeEnum
.
SYSTEM
.
getType
());
o
.
setCreateTime
(
build
LocalDate
Time
(
2021
,
2
,
1
));
o
.
setCreateTime
(
buildTime
(
2021
,
2
,
1
));
});
configMapper
.
insert
(
dbConfig
);
// 测试 name 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setName
(
"土豆"
)));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setName
(
"土豆"
)));
// 测试 key 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setConfigKey
(
"tudou"
)));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setConfigKey
(
"tudou"
)));
// 测试 type 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setType
(
ConfigTypeEnum
.
CUSTOM
.
getType
())));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setType
(
ConfigTypeEnum
.
CUSTOM
.
getType
())));
// 测试 createTime 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setCreateTime
(
buildLocalDate
Time
(
2021
,
1
,
1
))));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setCreateTime
(
build
Time
(
2021
,
1
,
1
))));
// 准备参数
ConfigPageReqVO
reqVO
=
new
ConfigPageReqVO
();
reqVO
.
setName
(
"艿"
);
reqVO
.
setKey
(
"nai"
);
reqVO
.
setType
(
ConfigTypeEnum
.
SYSTEM
.
getType
());
reqVO
.
setCreateTime
(
(
new
LocalDateTime
[]{
buildLocalDateTime
(
2021
,
1
,
15
),
buildLocalDateTime
(
2021
,
2
,
15
)}
));
reqVO
.
setCreateTime
(
buildBetweenTime
(
2021
,
1
,
15
,
2021
,
2
,
15
));
// 调用
PageResult
<
ConfigDO
>
pageResult
=
configService
.
getConfigPage
(
reqVO
);
...
...
@@ -188,23 +185,23 @@ public class ConfigServiceTest extends BaseDbUnitTest {
o
.
setName
(
"芋艿"
);
o
.
setConfigKey
(
"yunai"
);
o
.
setType
(
ConfigTypeEnum
.
SYSTEM
.
getType
());
o
.
setCreateTime
(
build
LocalDate
Time
(
2021
,
2
,
1
));
o
.
setCreateTime
(
buildTime
(
2021
,
2
,
1
));
});
configMapper
.
insert
(
dbConfig
);
// 测试 name 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setName
(
"土豆"
)));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setName
(
"土豆"
)));
// 测试 key 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setConfigKey
(
"tudou"
)));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setConfigKey
(
"tudou"
)));
// 测试 type 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setType
(
ConfigTypeEnum
.
CUSTOM
.
getType
())));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setType
(
ConfigTypeEnum
.
CUSTOM
.
getType
())));
// 测试 createTime 不匹配
configMapper
.
insert
(
ObjectUtils
.
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setCreateTime
(
buildLocalDate
Time
(
2021
,
1
,
1
))));
configMapper
.
insert
(
cloneIgnoreId
(
dbConfig
,
o
->
o
.
setCreateTime
(
build
Time
(
2021
,
1
,
1
))));
// 准备参数
ConfigExportReqVO
reqVO
=
new
ConfigExportReqVO
();
reqVO
.
setName
(
"艿"
);
reqVO
.
setKey
(
"nai"
);
reqVO
.
setType
(
ConfigTypeEnum
.
SYSTEM
.
getType
());
reqVO
.
setCreateTime
(
(
new
LocalDateTime
[]{
buildLocalDateTime
(
2021
,
1
,
15
),
buildLocalDateTime
(
2021
,
2
,
15
)}
));
reqVO
.
setCreateTime
(
buildBetweenTime
(
2021
,
1
,
15
,
2021
,
2
,
15
));
// 调用
List
<
ConfigDO
>
list
=
configService
.
getConfigList
(
reqVO
);
...
...
@@ -213,6 +210,21 @@ public class ConfigServiceTest extends BaseDbUnitTest {
assertPojoEquals
(
dbConfig
,
list
.
get
(
0
));
}
@Test
public
void
testGetConfig
()
{
// mock 数据
ConfigDO
dbConfig
=
randomConfigDO
();
configMapper
.
insert
(
dbConfig
);
// @Sql: 先插入出一条存在的数据
// 准备参数
Long
id
=
dbConfig
.
getId
();
// 调用
ConfigDO
config
=
configService
.
getConfig
(
id
);
// 断言
assertNotNull
(
config
);
assertPojoEquals
(
dbConfig
,
config
);
}
@Test
public
void
testGetConfigByKey
()
{
// mock 数据
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java
浏览文件 @
f620bc3f
...
...
@@ -31,6 +31,7 @@ import javax.annotation.Resource;
import
javax.validation.Valid
;
import
java.util.List
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
security
.
core
.
util
.
SecurityFrameworkUtils
.
getLoginUserId
;
import
static
cn
.
iocoder
.
yudao
.
module
.
infra
.
enums
.
ErrorCodeConstants
.
FILE_IS_EMPTY
;
...
...
@@ -99,7 +100,7 @@ public class UserProfileController {
@ApiOperation
(
"上传用户个人头像"
)
public
CommonResult
<
String
>
updateUserAvatar
(
@RequestParam
(
"avatarFile"
)
MultipartFile
file
)
throws
Exception
{
if
(
file
.
isEmpty
())
{
throw
ServiceExceptionUtil
.
exception
(
FILE_IS_EMPTY
);
throw
exception
(
FILE_IS_EMPTY
);
}
String
avatar
=
userService
.
updateUserAvatar
(
getLoginUserId
(),
file
.
getInputStream
());
return
success
(
avatar
);
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java
浏览文件 @
f620bc3f
...
...
@@ -31,6 +31,7 @@ import javax.annotation.Resource;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
system
.
dal
.
dataobject
.
permission
.
MenuDO
.
ID_ROOT
;
import
static
cn
.
iocoder
.
yudao
.
module
.
system
.
enums
.
ErrorCodeConstants
.*;
...
...
@@ -118,7 +119,7 @@ public class MenuServiceImpl implements MenuService {
public
void
updateMenu
(
MenuUpdateReqVO
reqVO
)
{
// 校验更新的菜单是否存在
if
(
menuMapper
.
selectById
(
reqVO
.
getId
())
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
MENU_NOT_EXISTS
);
throw
exception
(
MENU_NOT_EXISTS
);
}
// 校验父菜单存在
validateParentMenu
(
reqVO
.
getParentId
(),
reqVO
.
getId
());
...
...
@@ -138,11 +139,11 @@ public class MenuServiceImpl implements MenuService {
public
void
deleteMenu
(
Long
menuId
)
{
// 校验是否还有子菜单
if
(
menuMapper
.
selectCountByParentId
(
menuId
)
>
0
)
{
throw
ServiceExceptionUtil
.
exception
(
MENU_EXISTS_CHILDREN
);
throw
exception
(
MENU_EXISTS_CHILDREN
);
}
// 校验删除的菜单是否存在
if
(
menuMapper
.
selectById
(
menuId
)
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
MENU_NOT_EXISTS
);
throw
exception
(
MENU_NOT_EXISTS
);
}
// 标记删除
menuMapper
.
deleteById
(
menuId
);
...
...
@@ -229,17 +230,17 @@ public class MenuServiceImpl implements MenuService {
}
// 不能设置自己为父菜单
if
(
parentId
.
equals
(
childId
))
{
throw
ServiceExceptionUtil
.
exception
(
MENU_PARENT_ERROR
);
throw
exception
(
MENU_PARENT_ERROR
);
}
MenuDO
menu
=
menuMapper
.
selectById
(
parentId
);
// 父菜单不存在
if
(
menu
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
MENU_PARENT_NOT_EXISTS
);
throw
exception
(
MENU_PARENT_NOT_EXISTS
);
}
// 父菜单必须是目录或者菜单类型
if
(!
MenuTypeEnum
.
DIR
.
getType
().
equals
(
menu
.
getType
())
&&
!
MenuTypeEnum
.
MENU
.
getType
().
equals
(
menu
.
getType
()))
{
throw
ServiceExceptionUtil
.
exception
(
MENU_PARENT_NOT_DIR_OR_MENU
);
throw
exception
(
MENU_PARENT_NOT_DIR_OR_MENU
);
}
}
...
...
@@ -260,10 +261,10 @@ public class MenuServiceImpl implements MenuService {
}
// 如果 id 为空,说明不用比较是否为相同 id 的菜单
if
(
id
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
MENU_NAME_DUPLICATE
);
throw
exception
(
MENU_NAME_DUPLICATE
);
}
if
(!
menu
.
getId
().
equals
(
id
))
{
throw
ServiceExceptionUtil
.
exception
(
MENU_NAME_DUPLICATE
);
throw
exception
(
MENU_NAME_DUPLICATE
);
}
}
...
...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImpl.java
浏览文件 @
f620bc3f
...
...
@@ -39,7 +39,6 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
* 短信模板 Service 实现类
*
* @author zzf
* @date 2021/1/25 9:25
*/
@Service
@Slf4j
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论