From 090991f8232eda2ebbdeeb8f427ea7594191c191 Mon Sep 17 00:00:00 2001 From: Parker Date: Sun, 29 Nov 2020 23:46:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=91=E7=BA=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=A0=E6=B3=95=E9=80=90=E7=BA=A7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constants/MyBatisConstants.java | 2 ++ .../base/service/impl/CrudServiceImpl.java | 6 ++-- .../menu/service/impl/MenuServiceImpl.java | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) 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; + } }