diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/MyBatisConstants.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/MyBatisConstants.java index 686f1ba..0e96c09 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/MyBatisConstants.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/MyBatisConstants.java @@ -38,6 +38,8 @@ public final class MyBatisConstants { /** ID */ public static final String FIELD_ID = "id"; + /** PID */ + public static final String FIELD_PARENT_ID = "parentId"; /** 创建人 */ public static final String FIELD_CREATE_BY = "createBy"; /** 更新时间 */ diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/base/service/impl/CrudServiceImpl.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/base/service/impl/CrudServiceImpl.java index d672e7e..4810a7a 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/base/service/impl/CrudServiceImpl.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/base/service/impl/CrudServiceImpl.java @@ -197,8 +197,7 @@ public abstract class CrudServiceImpl, T extends BaseEnt @Override public List findList(QueryWrapper queryWrapper) { // 多租户处理 - TenantHandler tenantHandler = new TenantHandler(); - QueryWrapper qWrapper = tenantHandler.handler(entityClazz, queryWrapper); + QueryWrapper qWrapper = new TenantHandler().handler(entityClazz, queryWrapper); return super.list(qWrapper); } @@ -206,8 +205,7 @@ public abstract class CrudServiceImpl, T extends BaseEnt public List findAllList() { QueryBuilder queryBuilder = new GenQueryBuilder<>(); // 多租户处理 - TenantHandler tenantHandler = new TenantHandler(); - QueryWrapper qWrapper = tenantHandler.handler(entityClazz, queryBuilder.build()); + QueryWrapper qWrapper = new TenantHandler().handler(entityClazz, queryBuilder.build()); return super.list(qWrapper); } diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java index 9838860..6433413 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.opsli.api.wrapper.system.menu.MenuModel; import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.exception.ServiceException; +import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.WrapperUtil; import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.persistence.querybuilder.GenQueryBuilder; @@ -120,9 +121,14 @@ public class MenuServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); @@ -148,6 +155,11 @@ public class MenuServiceImpl extends CrudServiceImpl menuList = super.findList(queryWrapper); boolean ret = super.deleteAll(ids); + // 删除子数据 + for (String id : ids) { + this.deleteByParentId(id); + } + if(ret){ // 清空编号缓存 for (SysMenu sysMenu : menuList) { @@ -171,6 +183,27 @@ public class MenuServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); + QueryWrapper queryWrapper = queryBuilder.build(); + queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + List menuList = super.findList(queryWrapper); + for (SysMenu sysMenu : menuList) { + super.delete(sysMenu.getId()); + // 逐级删除子数据 + ret = this.deleteByParentId(sysMenu.getId()); + } + return ret; + } }