Commit 954b380a authored by 不期而遇's avatar 不期而遇

修复叶子节点

parent 7dcb9e80
...@@ -26,6 +26,7 @@ import cn.hutool.core.lang.Assert; ...@@ -26,6 +26,7 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.biz.impl.BaseBizImpl;
import net.mingsoft.base.dao.IBaseDao; import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.basic.util.PinYinUtil; import net.mingsoft.basic.util.PinYinUtil;
...@@ -207,6 +208,24 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i ...@@ -207,6 +208,24 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
categoryDao.deleteBatchIds(ids); categoryDao.deleteBatchIds(ids);
// 删除文章 // 删除文章
contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()])); contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()]));
//获取被删节点的父节点
CategoryEntity parentNode = categoryDao.selectById(category.getCategoryId());
//获取被删节点的所属栏目的其他节点
List<CategoryEntity> childNode = categoryDao.queryChildren(parentNode);
//判断删除的是否为主节点
if (parentNode != null) {
UpdateWrapper<CategoryEntity> 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);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment