From 6de8507f302a7b10c9fc4a54b3454993c13c47e5 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Fri, 21 Mar 2025 09:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=AE=A1=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canteen/core/allocation/api/AllocCanteenApi.java | 6 ++++++ .../canteen/service/impl/AllocAreaServiceImpl.java | 4 ---- .../com/bonus/canteen/core/auth/api/MgrAuthApi.java | 4 +++- .../core/auth/config/LeNiuDataPermissionHandler.java | 3 ++- .../main/resources/mapper/alloc/AllocAreaMapper.xml | 12 ------------ 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/api/AllocCanteenApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/api/AllocCanteenApi.java index 03ad04fc..d61b1fee 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/api/AllocCanteenApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/api/AllocCanteenApi.java @@ -14,6 +14,8 @@ import com.bonus.canteen.core.allocation.canteen.service.AllocAreaService; import com.bonus.canteen.core.allocation.canteen.service.AllocCanteenService; import com.bonus.canteen.core.allocation.canteen.service.AllocMealLineService; import com.bonus.canteen.core.allocation.canteen.vo.*; +import com.bonus.canteen.core.auth.config.LeNiuDataPermission; +import com.bonus.canteen.core.auth.enums.DataPermissionTypeEnum; import com.bonus.canteen.core.auth.po.MgrUserAuthPO; import com.bonus.canteen.core.common.enums.AllocCanteenTypeEnum; import com.bonus.canteen.core.common.utils.TenantContextHolder; @@ -251,6 +253,10 @@ public class AllocCanteenApi { return this.allocStallMapper.listAuthStallByUserRole(); } + @LeNiuDataPermission( + alias = "t1", + permissionType = DataPermissionTypeEnum.PERMISSION_AREA + ) public List listAreaByUserRole(MgrUserAuthPO mgrUserAuthPO) { return this.allocAreaMapper.listAreaByUserRole(mgrUserAuthPO); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocAreaServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocAreaServiceImpl.java index ec8945d5..a0731eb0 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocAreaServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocAreaServiceImpl.java @@ -201,11 +201,7 @@ public class AllocAreaServiceImpl extends ServiceImpl> getSystemAuthAreaTree() { - MgrUserAuthPO mgrUserAuthPO = this.mgrAuthApi.getUserAuthPO(); List areaList = ((AllocAreaMapper)this.baseMapper).listSystemArea(TenantContextHolder.getTenantId()); - if (GlobalConstants.SUPER_ADMIN_ROLE_KEY.equals(mgrUserAuthPO.getRoleCode())) { - areaList = new ArrayList<>(); - } List filterAreaTreeList = ((AllocAreaMapper)this.baseMapper).listAllTreeArea(); if (CollUtil.isNotEmpty(filterAreaTreeList)) { List filterAreaIdList = (List)filterAreaTreeList.stream().map(BaseTreeNode::getId).collect(Collectors.toList()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java index 2147cea0..8a545a4f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/api/MgrAuthApi.java @@ -131,7 +131,9 @@ public class MgrAuthApi { MgrUserAuthPO mgrUserAuthPO = this.getUserAuthPO(); if (!filterOtherRole) { return CollUtil.newArrayList(new AllocCanteenTreeVO[0]); - } else if (!ObjectUtil.equal(mgrUserAuthPO.getRoleType(), MgrRoleTypeV2Enum.ROLE_ADMIN.getKey()) && !ObjectUtil.equal(mgrUserAuthPO.getRoleType(), MgrRoleTypeV2Enum.ROLE_ORG.getKey())) { + } else if (!ObjectUtil.equal(mgrUserAuthPO.getRoleType(), MgrRoleTypeV2Enum.ROLE_ADMIN.getKey()) + && !ObjectUtil.equal(mgrUserAuthPO.getRoleCode(), GlobalConstants.SUPER_ADMIN_ROLE_KEY) + && !ObjectUtil.equal(mgrUserAuthPO.getRoleType(), MgrRoleTypeV2Enum.ROLE_ORG.getKey())) { return this.mgrRoleCanteenMapper.getTenantCanteen(excludeMiddle, tenantId, mgrUserAuthPO, delFlag); } else { List list = CollUtil.newArrayList(new AllocCanteenTreeVO[0]); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java index 074f7667..f993e727 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/auth/config/LeNiuDataPermissionHandler.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import com.bonus.canteen.core.auth.enums.DataPermissionTypeEnum; import com.bonus.canteen.core.auth.enums.RoleCodeV2Enum; import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.houqin.constant.GlobalConstants; import com.bonus.common.security.utils.SecurityUtils; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.HexValue; @@ -87,7 +88,7 @@ public class LeNiuDataPermissionHandler { private String getSqlByAliasAndPermissionType(Long userId, String roleCode, DataPermissionTypeEnum permissionType, String alias) { StringBuilder sb = new StringBuilder(); - if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key())) { + if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key()) || GlobalConstants.SUPER_ADMIN_ROLE_KEY.equals(roleCode)) { return ""; } else { if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_ORG, permissionType)) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocAreaMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocAreaMapper.xml index 9be9b051..d4def381 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocAreaMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocAreaMapper.xml @@ -61,17 +61,5 @@ t1.super_id FROM alloc_area t1 WHERE t1.if_del = 2 - - and EXISTS ( - SELECT null - FROM sys_role_area it1 - LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id - LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id - WHERE it2.del_flag = 0 - AND it2.role_key = #{authPO.roleCode} - AND it3.user_id = #{authPO.userId} - AND t1.area_id = it1.area_id - ) -