From c4b62788b53fa14008d8e76ae9d0e5b9f5d01b1b Mon Sep 17 00:00:00 2001 From: zlyx <1242874891@qq.com> Date: Thu, 30 Mar 2023 09:14:31 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9E=20LoginTenantVo=20?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E7=A7=9F=E6=88=B7=E5=AF=B9=E8=B1=A1=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20;=20update=20=E6=9B=B4=E6=96=B0=20AuthController#te?= =?UTF-8?q?nantList=20=E8=BF=94=E5=9B=9E=E7=A7=9F=E6=88=B7=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E4=BB=A5=E5=8F=8A=E7=A7=9F=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/web/controller/AuthController.java | 10 ++++++-- .../ruoyi/web/domain/vo/LoginTenantVo.java | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/domain/vo/LoginTenantVo.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/AuthController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/AuthController.java index 81af4dfa..d7f210e4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/AuthController.java @@ -9,10 +9,12 @@ import com.ruoyi.common.core.domain.model.SmsLoginBody; import com.ruoyi.common.core.utils.MapstructUtils; import com.ruoyi.common.core.utils.StreamUtils; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.tenant.helper.TenantHelper; import com.ruoyi.system.domain.bo.SysTenantBo; import com.ruoyi.system.domain.vo.SysTenantVo; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysTenantService; +import com.ruoyi.web.domain.vo.LoginTenantVo; import com.ruoyi.web.domain.vo.LoginVo; import com.ruoyi.web.domain.vo.TenantListVo; import com.ruoyi.web.service.SysLoginService; @@ -118,14 +120,18 @@ public class AuthController { * @return 租户列表 */ @GetMapping("/tenant/list") - public R> tenantList(HttpServletRequest request) throws Exception { + public R tenantList(HttpServletRequest request) throws Exception { List tenantList = tenantService.queryList(new SysTenantBo()); List voList = MapstructUtils.convert(tenantList, TenantListVo.class); // 获取域名 String host = new URL(request.getRequestURL().toString()).getHost(); // 根据域名进行筛选 List list = StreamUtils.filter(voList, vo -> StringUtils.equals(vo.getDomain(), host)); - return R.ok(CollUtil.isNotEmpty(list) ? list : voList); + // 返回对象 + LoginTenantVo vo = new LoginTenantVo(); + vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList); + vo.setTenantEnabled(TenantHelper.isEnable()); + return R.ok(vo); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/domain/vo/LoginTenantVo.java b/ruoyi-admin/src/main/java/com/ruoyi/web/domain/vo/LoginTenantVo.java new file mode 100644 index 00000000..cc42e962 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/domain/vo/LoginTenantVo.java @@ -0,0 +1,25 @@ +package com.ruoyi.web.domain.vo; + +import lombok.Data; + +import java.util.List; + +/** + * 登录租户对象 + * + * @author Michelle.Chung + */ +@Data +public class LoginTenantVo { + + /** + * 租户开关 + */ + private Boolean tenantEnabled; + + /** + * 租户对象列表 + */ + private List voList; + +}