Search in sources :

Example 1 with AdminLog

use of com.itrus.portal.db.AdminLog in project portal by ixinportal.

the class ItrusPortalUserLoginSucess method onAuthenticationSuccess.

public void onAuthenticationSuccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Authentication authentication) throws javax.servlet.ServletException, IOException {
    // 查询用户信息
    AdminExample adminex = new AdminExample();
    adminex.or().andAccountEqualTo(authentication.getName().toLowerCase());
    Admin admin = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    if (admin != null) {
        AdminLog adminlog = new AdminLog();
        adminlog.setAdmin(admin.getId());
        adminlog.setCreateTime(new Date());
        adminlog.setType("登录成功");
        adminlog.setInfo("登录成功,管理员: " + admin.getAccount());
        adminlog.setIp(request.getRemoteAddr());
        int ret = sqlSession.insert("com.itrus.portal.db.AdminLogMapper.insert", adminlog);
    // System.out.println("insert ret  = " + ret);
    }
    setDefaultTargetUrl("/index");
    super.onAuthenticationSuccess(request, response, authentication);
}
Also used : AdminLog(com.itrus.portal.db.AdminLog) Admin(com.itrus.portal.db.Admin) AdminExample(com.itrus.portal.db.AdminExample) Date(java.util.Date)

Aggregations

Admin (com.itrus.portal.db.Admin)1 AdminExample (com.itrus.portal.db.AdminExample)1 AdminLog (com.itrus.portal.db.AdminLog)1 Date (java.util.Date)1