From 954b380ad5ee37c2611040971ad5c70667944274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E6=9C=9F=E8=80=8C=E9=81=87?= <2680643943@qq.com> Date: Thu, 29 Apr 2021 09:32:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=B6=E5=AD=90=E8=8A=82?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/biz/impl/CategoryBizImpl.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java index 5e7a6d72..cfb4b9c9 100755 --- a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java +++ b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java @@ -26,6 +26,7 @@ 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 com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import net.mingsoft.base.biz.impl.BaseBizImpl; import net.mingsoft.base.dao.IBaseDao; import net.mingsoft.basic.util.PinYinUtil; @@ -207,6 +208,24 @@ public class CategoryBizImpl extends BaseBizImpl i categoryDao.deleteBatchIds(ids); // 删除文章 contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()])); + + //获取被删节点的父节点 + CategoryEntity parentNode = categoryDao.selectById(category.getCategoryId()); + //获取被删节点的所属栏目的其他节点 + List childNode = categoryDao.queryChildren(parentNode); + //判断删除的是否为主节点 + if (parentNode != null) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + + //是否还有子节点 + if (childNode.size() > 1) + updateWrapper.eq("id", parentNode.getId()).set("leaf", 0); + else + updateWrapper.eq("id", parentNode.getId()).set("leaf", 1); + + categoryDao.update(null, updateWrapper); + } + } }