From acf88d6533dded12de7ddc73aae7b871007f0a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=AE=87=E5=A5=87?= Date: Wed, 18 Jun 2025 20:58:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=90=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/SecurityUtils.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java index 9c6c7fbda..73b17e069 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java @@ -68,6 +68,51 @@ public class SecurityUtils { return false; } + /** + * 是否有指定档口的管理权限 + * + * @param storeId + * @return + */ + public static boolean isStoreSub(Long storeId) { + if (storeId == null) { + return false; + } + try { + Authentication auth = getAuthentication(); + if (auth != null) { + LoginUser user = (LoginUser) auth.getPrincipal(); + return user.getUser().getSubStoreIds().contains(storeId); + } + } catch (Exception e) { + log.error("判断档口管理权限异常", e); + } + return false; + } + + /** + * 是否有指定档口的管理/子账号权限 + * + * @param storeId + * @return + */ + public static boolean isStoreManagerOrSub(Long storeId) { + if (storeId == null) { + return false; + } + try { + Authentication auth = getAuthentication(); + if (auth != null) { + LoginUser user = (LoginUser) auth.getPrincipal(); + return user.getUser().getManagedStoreIds().contains(storeId) + || user.getUser().getSubStoreIds().contains(storeId); + } + } catch (Exception e) { + log.error("判断档口管理权限异常", e); + } + return false; + } + /** * 判断是否有指定角色中的任意一个 *