diff --git a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/RoleCategoryServiceImpl.java b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/RoleCategoryServiceImpl.java index c6b7260fc..beed9ed4c 100644 --- a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/RoleCategoryServiceImpl.java +++ b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/role/service/impl/RoleCategoryServiceImpl.java @@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.sys.modular.role.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; +import cn.stylefeng.roses.kernel.db.api.DbOperatorApi; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; import cn.stylefeng.roses.kernel.rule.pidset.CalcParentIdListUtil; import cn.stylefeng.roses.kernel.rule.pidset.callback.PidGetterService; @@ -13,11 +14,14 @@ import cn.stylefeng.roses.kernel.sys.modular.role.mapper.RoleCategoryMapper; import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleCategoryRequest; import cn.stylefeng.roses.kernel.sys.modular.role.service.RoleCategoryService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * 角色分类业务实现层 @@ -28,6 +32,9 @@ import java.util.List; @Service public class RoleCategoryServiceImpl extends ServiceImpl implements RoleCategoryService, PidGetterService { + @Resource + private DbOperatorApi dbOperatorApi; + @Override public List treeList(RoleCategoryRequest roleCategoryRequest) { LambdaQueryWrapper wrapper = this.createWrapper(roleCategoryRequest); @@ -53,8 +60,16 @@ public class RoleCategoryServiceImpl extends ServiceImpl childIdList = this.dbOperatorApi.findSubListByParentId("sys_role_category", "category_pids", "id", treeId); + childIdList.add(treeId); + + // 删除本节点 + 子节点 + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.in(RoleCategory::getId, childIdList); + this.remove(wrapper); } @Override