Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
MCMS
Commits
14b2d5db
"eladmin-system/src/vscode:/vscode.git/clone" did not exist on "b9aca9366d5e096445b624d37c0c05ba0e873f57"
Commit
14b2d5db
authored
Nov 03, 2020
by
xierz
Browse files
修改栏目-父节点判断
修改栏目-更新父节点叶子状态方式 新增栏目-新增栏目一定是叶子节点
parent
d68b4dd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java
View file @
14b2d5db
...
...
@@ -24,6 +24,7 @@ package net.mingsoft.cms.biz.impl;
import
cn.hutool.core.lang.Assert
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
net.mingsoft.base.biz.impl.BaseBizImpl
;
import
net.mingsoft.base.dao.IBaseDao
;
import
net.mingsoft.basic.util.BasicUtil
;
...
...
@@ -88,6 +89,10 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
}
}
categoryEntity
.
setLeaf
(
false
);
//如果是新增栏目一定是叶子节点
if
(
StrUtil
.
isEmpty
(
categoryEntity
.
getId
()))
{
categoryEntity
.
setLeaf
(
true
);
}
super
.
save
(
categoryEntity
);
//拼音存在则拼接id
if
(
categoryBizEntity
!=
null
){
...
...
@@ -190,14 +195,15 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
Assert
.
notNull
(
entity
);
CategoryEntity
categoryEntity
=
getById
(
entity
.
getId
());
//如果父级不为空并且修改了父级则需要更新父级
if
(!
entity
.
getCategoryId
().
equals
(
categoryEntity
.
getId
())){
if
(!
entity
.
getCategoryId
().
equals
(
categoryEntity
.
get
Category
Id
())){
//更新旧的父级
if
(
StrUtil
.
isNotBlank
(
categoryEntity
.
getCategoryId
())&&!
"0"
.
equals
(
categoryEntity
.
getCategoryId
())){
CategoryEntity
parent
=
getById
(
categoryEntity
.
getCategoryId
());
//如果修改了父级则需要判断父级是否还有子节点
boolean
leaf
=
parent
.
getLeaf
();
//查找不等于当前更新的分类子集,有则不是叶子节点
parent
.
setLeaf
(
count
(
lambdaQuery
().
eq
(
CategoryEntity:
:
getCategoryId
,
parent
.
getId
()).
ne
(
CategoryEntity:
:
getId
,
entity
.
getId
()))==
0
);
QueryWrapper
<
CategoryEntity
>
queryWrapper
=
new
QueryWrapper
<>();
parent
.
setLeaf
(
count
(
queryWrapper
.
eq
(
"category_id"
,
parent
.
getId
()).
ne
(
"id"
,
entity
.
getId
()))==
0
);
if
(
leaf
!=
parent
.
getLeaf
()){
updateById
(
parent
);
}
...
...
Write
Preview
Supports
Markdown
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