update 禁用租户

master
jay 2024-06-17 19:11:41 +08:00
parent 7a4eacc679
commit 4957532ff6
2 changed files with 63 additions and 62 deletions

View File

@ -49,7 +49,8 @@ public class TenantFilterAspect {
@AfterReturning(pointcut = "openSession()", returning = "session") @AfterReturning(pointcut = "openSession()", returning = "session")
public void afterOpenSession(Object session) { public void afterOpenSession(Object session) {
if(TenantHelper.isIgnore()){ // 租户管理需要商业版
if(!TenantHelper.isEnable() || TenantHelper.isIgnore()){
return; return;
} }
if (session instanceof Session) { if (session instanceof Session) {

View File

@ -1,61 +1,61 @@
/* ///*
* // *
* * | Licensed OPENIITA // * * | Licensed 未经许可不能去掉「OPENIITA」相关版权
* * +---------------------------------------------------------------------- // * * +----------------------------------------------------------------------
* * | Author: xw2sy@163.com // * * | Author: xw2sy@163.com
* * +---------------------------------------------------------------------- // * * +----------------------------------------------------------------------
* // *
* Copyright [2024] [OPENIITA] // * Copyright [2024] [OPENIITA]
* // *
* Licensed under the Apache License, Version 2.0 (the "License"); // * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. // * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at // * You may obtain a copy of the License at
* // *
* http://www.apache.org/licenses/LICENSE-2.0 // * http://www.apache.org/licenses/LICENSE-2.0
* // *
* Unless required by applicable law or agreed to in writing, software // * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, // * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and // * See the License for the specific language governing permissions and
* limitations under the License. // * limitations under the License.
* / // * /
*/ // */
//
package cc.iotkit.common.web.interceptor; //package cc.iotkit.common.web.interceptor;
//
import cn.dev33.satoken.context.SaHolder; //import cn.dev33.satoken.context.SaHolder;
import org.springframework.web.servlet.HandlerInterceptor; //import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView; //import org.springframework.web.servlet.ModelAndView;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
//
/** ///**
* id // * 新增租户拦截器拦截请求头中的租户id
* // *
* @author Tiger Chen // * @author Tiger Chen
* created on 2023/7/15 14:26 // * created on 2023/7/15 14:26
*/ // */
//
//
public class TenantInterceptor implements HandlerInterceptor { //public class TenantInterceptor implements HandlerInterceptor {
//
public static final String TENANT_ID = "Tenant-Id"; // public static final String TENANT_ID = "Tenant-Id";
//
@Override // @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { // public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
if (request.getHeader(TENANT_ID) != null) { // if (request.getHeader(TENANT_ID) != null) {
Long tenantId = Long.valueOf(request.getHeader(TENANT_ID)); // Long tenantId = Long.valueOf(request.getHeader(TENANT_ID));
SaHolder.getStorage().set("tenantId", tenantId); // SaHolder.getStorage().set("tenantId", tenantId);
} // }
return true; // return true;
} // }
//
@Override // @Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { // public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
} // }
//
@Override // @Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { // public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
} // }
} //}