Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
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
西魏
cms_sys
Commits
14b2d5db
Commit
14b2d5db
authored
Nov 03, 2020
by
xierz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改栏目-父节点判断
修改栏目-更新父节点叶子状态方式 新增栏目-新增栏目一定是叶子节点
parent
d68b4dd9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
CategoryBizImpl.java
src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java
+8
-2
No files found.
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
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