|
|
|
@@ -71,59 +71,86 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { |
|
|
|
} |
|
|
|
|
|
|
|
//集团版中针对某一商场的业务需要传递mallTenantId |
|
|
|
String mallTenantId = request.getHeader("mallTenantId"); |
|
|
|
if(StringUtils.isBlank(mallTenantId)){ |
|
|
|
mallTenantId = request.getParameter("mallTenantId"); |
|
|
|
} |
|
|
|
// String mallTenantId = request.getHeader("mallTenantId"); |
|
|
|
// if(StringUtils.isBlank(mallTenantId)){ |
|
|
|
// mallTenantId = request.getParameter("mallTenantId"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// String tenantId = null; |
|
|
|
// String parenTenantId = null; |
|
|
|
// boolean isChildMall = false; |
|
|
|
// if (!StringUtils.isBlank(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失效,请重新登录"); |
|
|
|
// } |
|
|
|
// if (StringUtils.isBlank(mallTenantId)) { |
|
|
|
// tenantId = user.getTenantId(); |
|
|
|
// parenTenantId = user.getParentTenantId(); |
|
|
|
// }else { |
|
|
|
// tenantId = mallTenantId; |
|
|
|
// parenTenantId = user.getTenantId(); |
|
|
|
// isChildMall = true; |
|
|
|
// } |
|
|
|
// request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); |
|
|
|
// request.setAttribute(Constant.TENANT_ID, tenantId); |
|
|
|
// request.setAttribute(Constant.REQUEST_C_USER_KEY, user); |
|
|
|
// request.setAttribute(Constant.APP_INFO, user.getAppinfo()); |
|
|
|
// request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); |
|
|
|
// if (StringUtils.isNotBlank(parenTenantId)) { |
|
|
|
// request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); |
|
|
|
// } |
|
|
|
// |
|
|
|
// }else if (!StringUtils.isBlank(bid)) { |
|
|
|
// WxMerchantBUser buser = wxMerchantBUserService.getById(Long.parseLong(bid)); |
|
|
|
// if (buser == null) { |
|
|
|
// throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (StringUtils.isBlank(mallTenantId)) { |
|
|
|
// tenantId = buser.getTenantId(); |
|
|
|
// parenTenantId = buser.getParentTenantId(); |
|
|
|
// }else { |
|
|
|
// tenantId = mallTenantId; |
|
|
|
// parenTenantId = buser.getTenantId(); |
|
|
|
// isChildMall = true; |
|
|
|
// } |
|
|
|
// request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); |
|
|
|
// request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); |
|
|
|
// request.setAttribute(Constant.TENANT_ID, tenantId); |
|
|
|
// if (StringUtils.isNotBlank(parenTenantId)) { |
|
|
|
// request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// 查询token信息 |
|
|
|
WxMerchantBUser buser = null; |
|
|
|
String tenantId = null; |
|
|
|
String parenTenantId = null; |
|
|
|
boolean isChildMall = false; |
|
|
|
if (!StringUtils.isBlank(token)) { |
|
|
|
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失效,请重新登录"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(mallTenantId)) { |
|
|
|
tenantId = user.getTenantId(); |
|
|
|
parenTenantId = user.getParentTenantId(); |
|
|
|
}else { |
|
|
|
tenantId = mallTenantId; |
|
|
|
parenTenantId = user.getTenantId(); |
|
|
|
isChildMall = true; |
|
|
|
} |
|
|
|
request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); |
|
|
|
request.setAttribute(Constant.TENANT_ID, tenantId); |
|
|
|
request.setAttribute(Constant.REQUEST_C_USER_KEY, user); |
|
|
|
request.setAttribute(Constant.APP_INFO, user.getAppinfo()); |
|
|
|
request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); |
|
|
|
if (StringUtils.isNotBlank(parenTenantId)) { |
|
|
|
request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); |
|
|
|
if(user.getUserId() != null){ |
|
|
|
buser = wxMerchantBUserService.getById(user.getUserId()); |
|
|
|
} |
|
|
|
|
|
|
|
}else if (!StringUtils.isBlank(bid)) { |
|
|
|
WxMerchantBUser buser = wxMerchantBUserService.getById(Long.parseLong(bid)); |
|
|
|
if (buser == null) { |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(mallTenantId)) { |
|
|
|
tenantId = buser.getTenantId(); |
|
|
|
parenTenantId = buser.getParentTenantId(); |
|
|
|
}else { |
|
|
|
tenantId = mallTenantId; |
|
|
|
parenTenantId = buser.getTenantId(); |
|
|
|
isChildMall = true; |
|
|
|
} |
|
|
|
request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); |
|
|
|
request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); |
|
|
|
request.setAttribute(Constant.TENANT_ID, tenantId); |
|
|
|
if (StringUtils.isNotBlank(parenTenantId)) { |
|
|
|
request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); |
|
|
|
} |
|
|
|
}else if (StringUtils.isNotBlank(bid)) { |
|
|
|
buser = wxMerchantBUserService.getById(Long.parseLong(bid)); |
|
|
|
} |
|
|
|
|
|
|
|
if (buser == null) { |
|
|
|
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); |
|
|
|
} |
|
|
|
tenantId = buser.getTenantId(); |
|
|
|
request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); |
|
|
|
request.setAttribute(Constant.TENANT_ID, buser.getTenantId()); |
|
|
|
if (StringUtils.isNotBlank(buser.getParentTenantId())) { |
|
|
|
parenTenantId = buser.getParentTenantId(); |
|
|
|
request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); |
|
|
|
} |
|
|
|
|
|
|
|
//如果是要不需要自动设置tenantI信息 |
|
|
|
TenantIgnore tenantIgnoreAnnotation = null; |
|
|
|
|