|
@@ -4,21 +4,26 @@ import java.util.List;
|
|
|
|
|
|
import javax.servlet.ServletRequest;
|
|
|
import javax.servlet.ServletResponse;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.authc.AuthenticationToken;
|
|
|
import org.apache.shiro.session.Session;
|
|
|
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import com.xt.js.gkaq.common.Constants;
|
|
|
import com.xt.js.gkaq.frame.model.ButtonModel;
|
|
|
import com.xt.js.gkaq.frame.model.GroupModelDto;
|
|
|
import com.xt.js.gkaq.frame.model.MenuModel;
|
|
|
+import com.xt.js.gkaq.frame.model.SysLogModel;
|
|
|
import com.xt.js.gkaq.frame.model.UserModel;
|
|
|
import com.xt.js.gkaq.frame.service.ButtonService;
|
|
|
import com.xt.js.gkaq.frame.service.GroupService;
|
|
|
import com.xt.js.gkaq.frame.service.MenuService;
|
|
|
+import com.xt.js.gkaq.frame.service.SysLogService;
|
|
|
import com.yuanxd.tools.utils.Assert;
|
|
|
|
|
|
/**
|
|
@@ -34,6 +39,10 @@ public class GkaqFormAuthenticationFilter extends FormAuthenticationFilter {
|
|
|
private MenuService menuService;
|
|
|
@Autowired
|
|
|
private ButtonService buttonService;
|
|
|
+ @Autowired
|
|
|
+ private SysLogService sysLogService;
|
|
|
+ // 日志对象
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(GkaqFormAuthenticationFilter.class);
|
|
|
|
|
|
@Override
|
|
|
protected boolean onLoginSuccess(AuthenticationToken token, org.apache.shiro.subject.Subject subject,
|
|
@@ -46,8 +55,24 @@ public class GkaqFormAuthenticationFilter extends FormAuthenticationFilter {
|
|
|
List<MenuModel> menuList = menuService.selectAllByUser(userGroup);
|
|
|
List<ButtonModel> btnList = buttonService.selectAllByUser(userGroup);
|
|
|
Session session = SecurityUtils.getSubject().getSession();
|
|
|
+ session.setAttribute(Constants.SESSION_KEY_USER, user);
|
|
|
session.setAttribute(Constants.SESSION_KEY_MENUS, menuList);
|
|
|
session.setAttribute(Constants.SESSION_KEY_BTNS, btnList);
|
|
|
+ // 登入日志
|
|
|
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
|
|
|
+ String clientIp = IpUtil.getIpAddr(httpRequest);
|
|
|
+ session.setAttribute(Constants.SESSION_KEY_IP, clientIp);
|
|
|
+
|
|
|
+ // 数据库日志
|
|
|
+ SysLogModel log = new SysLogModel();
|
|
|
+ log.setLogType(Constants.LOG_TYPE_3);
|
|
|
+ log.setLogPath(GkaqFormAuthenticationFilter.class.getName());
|
|
|
+ log.setLogParam("");
|
|
|
+ log.setLogMsg("用户:[" + user.getLoginName() + "|" + user.getRealName() + "]登入系统!");
|
|
|
+ log.setClientIp(clientIp);
|
|
|
+ // 保存数据库
|
|
|
+ sysLogService.save(log);
|
|
|
+ logger.info("生成系统日志[日志描述:{},客户端IP:{}]", log.getLogMsg(), clientIp);
|
|
|
return super.onLoginSuccess(token, subject, request, response);
|
|
|
}
|
|
|
|