@ModelAttribute()
public void getSessionUser() throws IOException, ServletException {
HttpSession session = getSession();
if (getLoginInfoFromSession()==null) {
session.setMaxInactiveInterval(60*60);
HttpServletRequest request = getRequest();
String userId = request.getParameter("userId");
String roleType = request.getParameter("roleType");
if(userId==null||roleType==null){
request.getRequestDispatcher(request.getContextPath() + "/pages/error/500.html").forward(request, getResponse());
// getResponse().sendRedirect(request.getContextPath() + "/pages/error/500.html");
return;
}
List<AdminUser> adminUserList = adminUserService.getListByProperty("loginId",userId);
LoginInfo loginInfo = new LoginInfo();
AdminUser adminUser = adminUserList.get(0);
if(adminUser.getSupplier()!=null&&AdminUser.ROLE_TYPE_SUPPLIER.equals(roleType)){
loginInfo.setSupplierId(adminUser.getSupplier().getId());
loginInfo.setSupplierName(adminUser.getSupplier().getSupplierName());
}
loginInfo.setRoleType(roleType);
loginInfo.setAdminUser(adminUser);
session.setAttribute(SESSION_LOGIN_INFO, loginInfo);
}
}
public void getSessionUser() throws IOException, ServletException {
HttpSession session = getSession();
if (getLoginInfoFromSession()==null) {
session.setMaxInactiveInterval(60*60);
HttpServletRequest request = getRequest();
String userId = request.getParameter("userId");
String roleType = request.getParameter("roleType");
if(userId==null||roleType==null){
request.getRequestDispatcher(request.getContextPath() + "/pages/error/500.html").forward(request, getResponse());
// getResponse().sendRedirect(request.getContextPath() + "/pages/error/500.html");
return;
}
List<AdminUser> adminUserList = adminUserService.getListByProperty("loginId",userId);
LoginInfo loginInfo = new LoginInfo();
AdminUser adminUser = adminUserList.get(0);
if(adminUser.getSupplier()!=null&&AdminUser.ROLE_TYPE_SUPPLIER.equals(roleType)){
loginInfo.setSupplierId(adminUser.getSupplier().getId());
loginInfo.setSupplierName(adminUser.getSupplier().getSupplierName());
}
loginInfo.setRoleType(roleType);
loginInfo.setAdminUser(adminUser);
session.setAttribute(SESSION_LOGIN_INFO, loginInfo);
}
}