|
|
@@ -9,6 +9,8 @@ import com.xueyi.common.core.utils.core.ObjectUtil; |
|
|
|
import com.xueyi.common.core.utils.core.StrUtil; |
|
|
|
import com.xueyi.common.security.auth.AuthUtil; |
|
|
|
import com.xueyi.common.security.utils.SecurityUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.web.method.HandlerMethod; |
|
|
|
import org.springframework.web.servlet.AsyncHandlerInterceptor; |
|
|
|
|
|
|
@@ -22,6 +24,7 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
* @author xueyi |
|
|
|
*/ |
|
|
|
public class HeaderInterceptor implements AsyncHandlerInterceptor { |
|
|
|
private Logger logger = LoggerFactory.getLogger(HeaderInterceptor.class); |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|
|
@@ -42,12 +45,14 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor { |
|
|
|
|
|
|
|
String token = SecurityUtils.getToken(); |
|
|
|
|
|
|
|
System.err.println(SecurityUtils.getAccountType()); |
|
|
|
if (StrUtil.isNotEmpty(token)) { |
|
|
|
SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); |
|
|
|
SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); |
|
|
|
SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); |
|
|
|
SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); |
|
|
|
logger.info("IsLessor:{}",JwtUtil.getIsLessor(token)); |
|
|
|
if (!(("Y").equals(JwtUtil.getIsLessor(token))|| JwtUtil.getIsLessor(token).equals("1"))) {//如果是超管租户,则不执行以下 |
|
|
|
SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); |
|
|
|
SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); |
|
|
|
SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); |
|
|
|
SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); |
|
|
|
} |
|
|
|
|
|
|
|
TenantConstants.AccountType accountType = TenantConstants.AccountType.getByCode(SecurityUtils.getAccountType()); |
|
|
|
if(ObjectUtil.isNotNull(accountType)) { |
|
|
|