fix cast exception

yixian 5 years ago
parent 50ba01ce48
commit f590a95bb8

@ -42,8 +42,12 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Method method = ((HandlerMethod) handler).getMethod();
return handleMethod(method, request, response) && super.preHandle(request, response, handler);
if (handler instanceof HandlerMethod) {
Method method = ((HandlerMethod) handler).getMethod();
return handleMethod(method, request, response) && super.preHandle(request, response, handler);
} else {
return super.preHandle(request, response, handler);
}
}
private boolean handleMethod(Method method, HttpServletRequest request, HttpServletResponse response) {
@ -75,7 +79,7 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
}
if (ex != null) {
String funcId = clazz.getSimpleName() + "." + method.getName();
checkPartnerPermission(request, partner, partnerStatusKey, managerStatusKey,funcId);
checkPartnerPermission(request, partner, partnerStatusKey, managerStatusKey, funcId);
}
return true;
}
@ -85,11 +89,11 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
return true;
}
String funcId = clazz.getSimpleName() + "." + method.getName();
checkPartnerPermission(request, partner, partnerStatusKey, managerStatusKey,funcId);
checkPartnerPermission(request, partner, partnerStatusKey, managerStatusKey, funcId);
return true;
}
private void checkPartnerPermission(HttpServletRequest request, RequirePartner partner, String partnerStatusKey, String managerStatusKey,String funcId) {
private void checkPartnerPermission(HttpServletRequest request, RequirePartner partner, String partnerStatusKey, String managerStatusKey, String funcId) {
if (StringUtils.isEmpty(partnerStatusKey) && StringUtils.isEmpty(managerStatusKey)) {
throw new ForbiddenException("error.permission.not_login");
}
@ -108,7 +112,7 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
}
JSONObject func = permissionPartnerManager.getPartnerFuncById(funcId);
if(func!=null && StringUtils.isNotEmpty(func.getString("module_id"))){
if (func != null && StringUtils.isNotEmpty(func.getString("module_id"))) {
JSONArray arr = loginUser.getJSONArray("available_module_ids");
if (arr == null || !arr.contains(func.getString("module_id"))) {
logger.info(partner.toString());

Loading…
Cancel
Save