Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
997d98bb
Commit
997d98bb
authored
Jun 17, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字典删除调整
parent
02c3f3d8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
1 deletion
+58
-1
ErrorCodes.java
....cloud.plus.v1/yifu/common/core/exception/ErrorCodes.java
+9
-0
messages_zh_CN.properties
...on-core/src/main/resources/i18n/messages_zh_CN.properties
+2
-0
DictController.java
...u.cloud.plus.v1/yifu/admin/controller/DictController.java
+18
-1
SysDictItemService.java
....cloud.plus.v1/yifu/admin/service/SysDictItemService.java
+4
-0
SysDictItemServiceImpl.java
...us.v1/yifu/admin/service/impl/SysDictItemServiceImpl.java
+25
-0
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/exception/ErrorCodes.java
View file @
997d98bb
...
...
@@ -151,4 +151,13 @@ public interface ErrorCodes {
* 已存在对应值的字典项
*/
String
SYS_DICT_ITEM_ADD_VALUE_EXIST
=
"sys.dict.item.add.value.exist"
;
/**
* 存在下级字典,禁止删除
*/
String
SYS_DICT_DELETE_EXIST_CHILD
=
"sys.dict.delete.exist.child"
;
/**
* 存在下级字典项值,禁止删除
*/
String
SYS_DICT_ITEM_DELETE_EXIST_CHILD
=
"sys.dict.item.delete.exist.child"
;
}
yifu-common/yifu-common-core/src/main/resources/i18n/messages_zh_CN.properties
View file @
997d98bb
...
...
@@ -30,6 +30,8 @@ sys.dict.update.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u8
sys.dict.delete.existing
=
\u
5B57
\u5178\u
5B58
\u5728\u
4E0B
\u
7EA7
\u8282\u
70B9
\u
4E0D
\u
80FD
\u5220\u9664
sys.dict.add.type.exist
=
\u
5DF2
\u
5B58
\u5728\u
5BF9
\u
5E94
\u
7F16
\u7801\u7684\u
5B57
\u5178
sys.dict.item.add.value.exist
=
\u
5DF2
\u
5B58
\u5728\u
5BF9
\u
5E94
\u
503C
\u7684\u
5B57
\u5178\u9879
sys.dict.delete.exist.child
=
\u
5B58
\u5728\u
4E0B
\u
7EA7
\u
5B57
\u5178\u
FF0C
\u7981\u
6B62
\u5220\u9664
sys.dict.item.delete.exist.child
=
\u
5B58
\u5728\u
4E0B
\u
7EA7
\u
5B57
\u5178\u9879\u
503C
\u
FF0C
\u7981\u
6B62
\u5220\u9664
sys.role.delete.system
=
\u
7CFB
\u
7EDF
\u5185\u
7F6E
\u
89D2
\u8272\u
4E0D
\u
80FD
\u5220\u9664
sys.role.update.system
=
\u
7CFB
\u
7EDF
\u5185\u
7F6E
\u
89D2
\u8272\u
4E0D
\u
80FD
\u
4FEE
\u6539
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/DictController.java
View file @
997d98bb
...
...
@@ -124,6 +124,16 @@ public class DictController {
@DeleteMapping
(
"/{id:\\d+}"
)
@PreAuthorize
(
"@pms.hasPermission('sys_dict_del')"
)
public
R
removeById
(
@PathVariable
Long
id
)
{
SysDict
sysDict
=
sysDictService
.
getById
(
id
);
if
(
Common
.
isNotNull
(
sysDict
)){
SysDict
dict
=
sysDictService
.
getOne
(
Wrappers
.<
SysDict
>
query
().
lambda
()
.
eq
(
SysDict:
:
getParentItemType
,
sysDict
.
getType
())
.
eq
(
SysDict:
:
getDelFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
dict
)){
return
R
.
failed
(
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_DICT_DELETE_EXIST_CHILD
));
}
}
sysDictService
.
removeDict
(
id
);
return
R
.
ok
();
}
...
...
@@ -157,7 +167,7 @@ public class DictController {
*/
@GetMapping
(
"/item/page"
)
public
R
<
IPage
<
SysDictItem
>>
getSysDictItemPage
(
Page
page
,
SysDictItem
sysDictItem
)
{
return
R
.
ok
(
sysDictItemService
.
page
(
page
,
Wrappers
.
query
(
sysDictItem
)
));
return
R
.
ok
(
sysDictItemService
.
page
Item
(
page
,
sysDictItem
));
}
/**
...
...
@@ -242,6 +252,13 @@ public class DictController {
@SysLog
(
"删除字典项"
)
@DeleteMapping
(
"/item/{id:\\d+}"
)
public
R
removeDictItemById
(
@PathVariable
Long
id
)
{
SysDictItem
item
=
sysDictItemService
.
getOne
(
Wrappers
.<
SysDictItem
>
query
().
lambda
()
.
eq
(
SysDictItem:
:
getParentId
,
id
)
.
eq
(
SysDictItem:
:
getDelFlag
,
CommonConstants
.
ZERO_STRING
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
item
)){
return
R
.
failed
(
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_DICT_ITEM_DELETE_EXIST_CHILD
));
}
return
R
.
ok
(
sysDictItemService
.
removeDictItem
(
id
));
}
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/SysDictItemService.java
View file @
997d98bb
...
...
@@ -16,6 +16,8 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
service
;
import
cn.hutool.core.lang.tree.Tree
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem
;
...
...
@@ -50,4 +52,6 @@ public interface SysDictItemService extends IService<SysDictItem> {
* @return
*/
List
<
Tree
<
Long
>>
treeMenu
(
boolean
lazy
,
Long
parentId
);
IPage
<
SysDictItem
>
pageItem
(
Page
page
,
SysDictItem
sysDictItem
);
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysDictItemServiceImpl.java
View file @
997d98bb
...
...
@@ -19,10 +19,15 @@ import cn.hutool.core.collection.CollUtil;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.TreeNode
;
import
cn.hutool.core.lang.tree.TreeUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService
;
...
...
@@ -31,6 +36,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.enums.DictTypeEnum
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.stereotype.Service
;
...
...
@@ -117,6 +123,25 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
return
TreeUtil
.
build
(
collect
,
parent
);
}
@Override
public
IPage
<
SysDictItem
>
pageItem
(
Page
page
,
SysDictItem
sysDictItem
)
{
return
baseMapper
.
selectPage
(
page
,
buildQueryWrapper
(
sysDictItem
));
}
/**
* 构建查询的 wrapper
* @param sysDictItem 查询条件
* @return LambdaQueryWrapper
*/
private
LambdaQueryWrapper
buildQueryWrapper
(
SysDictItem
sysDictItem
)
{
LambdaQueryWrapper
<
SysDictItem
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
StrUtil
.
isNotBlank
(
sysDictItem
.
getType
())){
wrapper
.
likeRight
(
SysDictItem:
:
getType
,
sysDictItem
.
getType
());
}
wrapper
.
orderByAsc
(
SysDictItem:
:
getSortOrder
);
return
wrapper
;
}
@NotNull
private
Function
<
SysDictItem
,
TreeNode
<
Long
>>
getNodeFunction
()
{
return
sysDictItem
->
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment