mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix BasicErrorController's package path
This commit is contained in:
parent
d0d85ead52
commit
25d3298b71
@ -27,10 +27,11 @@ import com.chatopera.cc.model.User;
|
|||||||
import com.chatopera.cc.proxy.AgentSessionProxy;
|
import com.chatopera.cc.proxy.AgentSessionProxy;
|
||||||
import com.chatopera.cc.proxy.UserProxy;
|
import com.chatopera.cc.proxy.UserProxy;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.boot.autoconfigure.web.BasicErrorController;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
@ -38,15 +39,37 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(UserInterceptorHandler.class);
|
|
||||||
private static UserProxy userProxy;
|
private static UserProxy userProxy;
|
||||||
private static AgentSessionProxy agentSessionProxy;
|
private static AgentSessionProxy agentSessionProxy;
|
||||||
private static Integer webimport;
|
private static Integer webIMPort;
|
||||||
|
|
||||||
|
private static Integer getWebIMPort() {
|
||||||
|
if (webIMPort == null) {
|
||||||
|
webIMPort = MainContext.getContext().getBean(MessagingServerConfigure.class).getWebIMPort();
|
||||||
|
}
|
||||||
|
return webIMPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UserProxy getUserProxy() {
|
||||||
|
if (userProxy == null) {
|
||||||
|
userProxy = MainContext.getContext().getBean(UserProxy.class);
|
||||||
|
}
|
||||||
|
return userProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AgentSessionProxy getAgentSessionProxy() {
|
||||||
|
if (agentSessionProxy == null) {
|
||||||
|
agentSessionProxy = MainContext.getContext().getBean(AgentSessionProxy.class);
|
||||||
|
}
|
||||||
|
return agentSessionProxy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, Object handler)
|
public boolean preHandle(@NonNull final HttpServletRequest request, @NonNull final HttpServletResponse response,
|
||||||
throws Exception {
|
@NonNull Object handler) throws Exception {
|
||||||
boolean filter = false;
|
boolean filter = false;
|
||||||
User user = (User) request.getSession(true).getAttribute(Constants.USER_SESSION_NAME);
|
User user = (User) request.getSession(true).getAttribute(Constants.USER_SESSION_NAME);
|
||||||
|
|
||||||
@ -57,7 +80,7 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
|||||||
filter = true;
|
filter = true;
|
||||||
if (user != null && StringUtils.isNotBlank(user.getId())) {
|
if (user != null && StringUtils.isNotBlank(user.getId())) {
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 每次刷新用户的组织机构、角色和权限
|
* 每次刷新用户的组织机构、角色和权限
|
||||||
* TODO 此处代码执行频率高,但是并不是每次都要执行,存在很多冗余
|
* TODO 此处代码执行频率高,但是并不是每次都要执行,存在很多冗余
|
||||||
* 待用更好的方法实现
|
* 待用更好的方法实现
|
||||||
@ -83,9 +106,8 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postHandle(
|
public void postHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler,
|
||||||
HttpServletRequest request, HttpServletResponse response, Object arg2,
|
@Nullable ModelAndView view) {
|
||||||
ModelAndView view) {
|
|
||||||
final User user = (User) request.getSession().getAttribute(Constants.USER_SESSION_NAME);
|
final User user = (User) request.getSession().getAttribute(Constants.USER_SESSION_NAME);
|
||||||
final String infoace = (String) request.getSession().getAttribute(
|
final String infoace = (String) request.getSession().getAttribute(
|
||||||
Constants.CSKEFU_SYSTEM_INFOACQ); //进入信息采集模式
|
Constants.CSKEFU_SYSTEM_INFOACQ); //进入信息采集模式
|
||||||
@ -107,7 +129,7 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
|||||||
}
|
}
|
||||||
view.addObject("hostname", request.getServerName());
|
view.addObject("hostname", request.getServerName());
|
||||||
|
|
||||||
HandlerMethod handlerMethod = (HandlerMethod) arg2;
|
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||||
Menu menu = handlerMethod.getMethod().getAnnotation(Menu.class);
|
Menu menu = handlerMethod.getMethod().getAnnotation(Menu.class);
|
||||||
if (menu != null) {
|
if (menu != null) {
|
||||||
view.addObject("subtype", menu.subtype());
|
view.addObject("subtype", menu.subtype());
|
||||||
@ -119,7 +141,7 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
|||||||
if (StringUtils.isNotBlank(infoace)) {
|
if (StringUtils.isNotBlank(infoace)) {
|
||||||
view.addObject("infoace", infoace); //进入信息采集模式
|
view.addObject("infoace", infoace); //进入信息采集模式
|
||||||
}
|
}
|
||||||
view.addObject("webimport", getWebimport());
|
view.addObject("webimport", getWebIMPort());
|
||||||
view.addObject("sessionid", MainUtils.getContextID(request.getSession().getId()));
|
view.addObject("sessionid", MainUtils.getContextID(request.getSession().getId()));
|
||||||
|
|
||||||
view.addObject("models", MainContext.getModules());
|
view.addObject("models", MainContext.getModules());
|
||||||
@ -129,11 +151,11 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
|||||||
"agentStatusReport",
|
"agentStatusReport",
|
||||||
ACDServiceRouter.getAcdWorkMonitor().getAgentReport(user.getOrgi()));
|
ACDServiceRouter.getAcdWorkMonitor().getAgentReport(user.getOrgi()));
|
||||||
}
|
}
|
||||||
/**
|
/*
|
||||||
* WebIM共享用户
|
* WebIM共享用户
|
||||||
*/
|
*/
|
||||||
User imUser = (User) request.getSession().getAttribute(Constants.IM_USER_SESSION_NAME);
|
User imUser = (User) request.getSession().getAttribute(Constants.IM_USER_SESSION_NAME);
|
||||||
if (imUser == null && view != null) {
|
if (imUser == null) {
|
||||||
imUser = new User();
|
imUser = new User();
|
||||||
imUser.setUsername(Constants.GUEST_USER);
|
imUser.setUsername(Constants.GUEST_USER);
|
||||||
imUser.setId(MainUtils.getContextID(request.getSession(true).getId()));
|
imUser.setId(MainUtils.getContextID(request.getSession(true).getId()));
|
||||||
@ -165,30 +187,7 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, @Nullable Exception ex) {
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static Integer getWebimport() {
|
|
||||||
if (webimport == null) {
|
|
||||||
webimport = MainContext.getContext().getBean(MessagingServerConfigure.class).getWebIMPort();
|
|
||||||
}
|
|
||||||
return webimport;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static UserProxy getUserProxy() {
|
|
||||||
if (userProxy == null) {
|
|
||||||
userProxy = MainContext.getContext().getBean(UserProxy.class);
|
|
||||||
}
|
|
||||||
return userProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AgentSessionProxy getAgentSessionProxy() {
|
|
||||||
if (agentSessionProxy == null) {
|
|
||||||
agentSessionProxy = MainContext.getContext().getBean(AgentSessionProxy.class);
|
|
||||||
}
|
|
||||||
return agentSessionProxy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user