From ccea9cd4ab246325360397e61719f7e080314034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 21 Jun 2024 15:52:39 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=20=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E7=99=BB=E5=BD=95=E4=B9=8B=E5=90=8E=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=A2=AB=E5=9F=9F=E5=90=8D=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/TokenController.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ruoyi-auth/src/main/java/org/dromara/auth/controller/TokenController.java b/ruoyi-auth/src/main/java/org/dromara/auth/controller/TokenController.java index 94cef461..8de19740 100644 --- a/ruoyi-auth/src/main/java/org/dromara/auth/controller/TokenController.java +++ b/ruoyi-auth/src/main/java/org/dromara/auth/controller/TokenController.java @@ -1,5 +1,6 @@ package org.dromara.auth.controller; +import cn.dev33.satoken.exception.NotLoginException; import cn.hutool.core.codec.Base64; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; @@ -191,8 +192,26 @@ public class TokenController { */ @GetMapping("/tenant/list") public R tenantList(HttpServletRequest request) throws Exception { + // 返回对象 + LoginTenantVo result = new LoginTenantVo(); + boolean enable = TenantHelper.isEnable(); + result.setTenantEnabled(enable); + // 如果未开启租户这直接返回 + if (!enable) { + return R.ok(result); + } + List tenantList = remoteTenantService.queryList(); List voList = MapstructUtils.convert(tenantList, TenantListVo.class); + try { + // 如果只超管返回所有租户 + if (LoginHelper.isSuperAdmin()) { + result.setVoList(voList); + return R.ok(result); + } + } catch (NotLoginException ignored) { + } + // 获取域名 String host; String referer = request.getHeader("referer"); @@ -205,11 +224,8 @@ public class TokenController { // 根据域名进行筛选 List list = StreamUtils.filter(voList, vo -> StringUtils.equals(vo.getDomain(), host)); - // 返回对象 - LoginTenantVo vo = new LoginTenantVo(); - vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList); - vo.setTenantEnabled(TenantHelper.isEnable()); - return R.ok(vo); + result.setVoList(CollUtil.isNotEmpty(list) ? list : voList); + return R.ok(result); } }