From 535d3c9c01839d58ea65378fbc71e98a511cc49c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 5 Dec 2021 00:12:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86=E7=95=8C=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=90=E8=BE=93=E5=85=A5=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/SecurityConfiguration.java | 6 ++-- .../tenant/SysTenantController.java | 29 +++++++++++++++ yudao-admin-ui/src/api/system/tenant.js | 12 +++++++ yudao-admin-ui/src/views/login.vue | 35 ++++++++++++++----- 4 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/tenant/SysTenantController.java create mode 100644 yudao-admin-ui/src/api/system/tenant.js diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java index 8bb4bc9a6..e99c106b4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java @@ -22,9 +22,11 @@ public class SecurityConfiguration { @Bean public Customizer.ExpressionInterceptUrlRegistry> authorizeRequestsCustomizer() { return registry -> { - // 通用的接口,可匿名访问 TODO 芋艿:需要抽象出去 + // 验证码的接口 registry.antMatchers(api("/system/captcha/**")).anonymous(); - // Spring Boot Admin Server 的安全配置 TODO 芋艿:需要抽象出去 + // 获得租户编号的接口 + registry.antMatchers(api("/system/tenant/get-id-by-name")).anonymous(); + // Spring Boot Admin Server 的安全配置 registry.antMatchers(adminSeverContextPath).anonymous() .antMatchers(adminSeverContextPath + "/**").anonymous(); // 短信回调 API diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/tenant/SysTenantController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/tenant/SysTenantController.java new file mode 100644 index 000000000..9d91b740e --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/tenant/SysTenantController.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.adminserver.modules.system.controller.tenant; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Objects; + +@Api(tags = "租户") +@RestController +@RequestMapping("/system/tenant") +public class SysTenantController { + + @GetMapping("/get-id-by-name") + @ApiOperation(value = "使用租户名,获得租户编号", notes = "登录界面,根据用户的租户名,获得租户编号") + @ApiImplicitParam(name = "name", value = "租户名", required = true, example = "芋道源码", dataTypeClass = Long.class) + public CommonResult getTenantIdByName(@RequestParam("name") String name) { + if (Objects.equals("芋道源码", name)) { + return CommonResult.success(0L); + } + return CommonResult.success(null); + } + +} diff --git a/yudao-admin-ui/src/api/system/tenant.js b/yudao-admin-ui/src/api/system/tenant.js new file mode 100644 index 000000000..32853984a --- /dev/null +++ b/yudao-admin-ui/src/api/system/tenant.js @@ -0,0 +1,12 @@ +import request from '@/utils/request' + +// 使用租户名,获得租户编号 +export function getTenantIdByName(name) { + return request({ + url: '/system/tenant/get-id-by-name', + method: 'get', + params: { + name + } + }) +} diff --git a/yudao-admin-ui/src/views/login.vue b/yudao-admin-ui/src/views/login.vue index b098e13ad..f8a3f72a0 100644 --- a/yudao-admin-ui/src/views/login.vue +++ b/yudao-admin-ui/src/views/login.vue @@ -2,8 +2,8 @@