|
|
|
@@ -10,6 +10,7 @@ import com.iformall.domain.po.MallUserInfo; |
|
|
|
import com.iformall.domain.po.WxMall; |
|
|
|
import com.iformall.domain.po.WxMerchantBUser; |
|
|
|
import com.iformall.domain.po.base.BaseCUserEntity; |
|
|
|
import com.iformall.enums.EnumAppPlat; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.CUserTokenService; |
|
|
|
import com.iformall.service.MallUserInfoService; |
|
|
|
@@ -77,14 +78,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { |
|
|
|
bid = request.getParameter("bid"); |
|
|
|
} |
|
|
|
|
|
|
|
//商管操作台 |
|
|
|
String adminUserId = request.getHeader("adminUserId"); |
|
|
|
if(StringUtils.isBlank(adminUserId)){ |
|
|
|
adminUserId = request.getParameter("adminUserId"); |
|
|
|
} |
|
|
|
|
|
|
|
//token为空, |
|
|
|
if(StringUtils.isBlank(token) && StringUtils.isBlank(bid) && StringUtils.isBlank(adminUserId)){ |
|
|
|
if(StringUtils.isBlank(token) && StringUtils.isBlank(bid)){ |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -99,23 +94,27 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { |
|
|
|
String parenTenantId = null; |
|
|
|
MallUserInfo adminUser = null; |
|
|
|
if (StringUtils.isNotBlank(token)) { |
|
|
|
BaseCUserEntity user = cUserTokenService.getBByToken(token); |
|
|
|
if (user == null || user.getExpireTime().getTime() < System.currentTimeMillis()) { |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); |
|
|
|
} |
|
|
|
request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); |
|
|
|
request.setAttribute(Constant.REQUEST_C_USER_KEY, user); |
|
|
|
if(user.getUserId() != null){ |
|
|
|
buser = wxMerchantBUserService.getById(user.getUserId()); |
|
|
|
} |
|
|
|
//商管操作台 |
|
|
|
if(token.endsWith(Constant.TOKEN_ADMIN_END)){ |
|
|
|
String[] tokens = token.split(":"); |
|
|
|
adminUser = mallUserInfoService.getById(Long.parseLong(tokens[0])); |
|
|
|
if (null == adminUser) { |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " adminUserId失效,请重新登录"); |
|
|
|
} |
|
|
|
request.setAttribute(Constant.REQUEST_MALL_USER_KEY, adminUser); |
|
|
|
}else { |
|
|
|
BaseCUserEntity user = cUserTokenService.getBByToken(token); |
|
|
|
if (user == null || user.getExpireTime().getTime() < System.currentTimeMillis()) { |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); |
|
|
|
} |
|
|
|
request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); |
|
|
|
request.setAttribute(Constant.REQUEST_C_USER_KEY, user); |
|
|
|
if(user.getUserId() != null){ |
|
|
|
buser = wxMerchantBUserService.getById(user.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (StringUtils.isNotBlank(bid)) { |
|
|
|
buser = wxMerchantBUserService.getById(Long.parseLong(bid)); |
|
|
|
}else if (StringUtils.isNotBlank(adminUserId)) { |
|
|
|
adminUser = mallUserInfoService.getById(Long.parseLong(adminUserId)); |
|
|
|
if (null == adminUser) { |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " adminUserId失效,请重新登录"); |
|
|
|
} |
|
|
|
request.setAttribute(Constant.REQUEST_MALL_USER_KEY, adminUser); |
|
|
|
} |
|
|
|
|
|
|
|
if (buser == null && adminUser == null) { |
|
|
|
|