Commit 67108a46 authored by Quxl's avatar Quxl

x

parent 183f9bd4
...@@ -2,8 +2,6 @@ package com.egolm.film.api.service; ...@@ -2,8 +2,6 @@ package com.egolm.film.api.service;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -25,6 +23,4 @@ public interface TokenService { ...@@ -25,6 +23,4 @@ public interface TokenService {
boolean isLoginByToken(String token); boolean isLoginByToken(String token);
void doLog(HttpServletRequest request);
} }
package com.egolm.film.api.service.impl; package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil; import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.AdminTokenService; import com.egolm.film.api.service.AdminTokenService;
...@@ -112,19 +109,4 @@ public class AdminTokenServiceImpl implements AdminTokenService { ...@@ -112,19 +109,4 @@ public class AdminTokenServiceImpl implements AdminTokenService {
} }
} }
@Override
public void doLog(HttpServletRequest request) {
LoginToken token = this.getToken();
String loginid = String.valueOf(token.getId());
Date now = new Date();
String path = request.getRequestURI().replace(request.getContextPath(), "");
String prefix = path.split("/")[1];
String content = JSON.toJSONString(request.getParameterMap());
String ip = ServletUtil.remoteIp(request);
String user_agent = request.getHeader("User-Agent");
String sql = "insert into fc_logs (type, loginid, prefix, path, ip, content, user_agent, create_time) values (?, ?, ?, ?, ?, ?, ?, ?)";
Object[] objs = new Object[]{LOG_TYPE, loginid, prefix, path, ip, content, user_agent, now};
jdbcTemplate.executeUpdate(sql, objs);
}
} }
package com.egolm.film.api.service.impl; package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil; import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.MemberService; import com.egolm.film.api.service.MemberService;
...@@ -115,20 +112,5 @@ public class MemberTokenServiceImpl implements MemberTokenService { ...@@ -115,20 +112,5 @@ public class MemberTokenServiceImpl implements MemberTokenService {
return false; return false;
} }
} }
@Override
public void doLog(HttpServletRequest request) {
LoginToken token = this.getToken();
String loginid = String.valueOf(token.getId());
Date now = new Date();
String path = request.getRequestURI().replace(request.getContextPath(), "");
String prefix = path.split("/")[1];
String content = JSON.toJSONString(request.getParameterMap());
String ip = ServletUtil.remoteIp(request);
String user_agent = request.getHeader("User-Agent");
String sql = "insert into fc_logs (type, loginid, prefix, path, ip, content, user_agent, create_time) values (?, ?, ?, ?, ?, ?, ?, ?)";
Object[] objs = new Object[]{LOG_TYPE, loginid, prefix, path, ip, content, user_agent, now};
jdbcTemplate.executeUpdate(sql, objs);
}
} }
...@@ -4,13 +4,11 @@ import java.util.Date; ...@@ -4,13 +4,11 @@ import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil; import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.Messages; import com.egolm.film.api.service.Messages;
...@@ -108,20 +106,4 @@ public class UserTokenServiceImpl implements UserTokenService { ...@@ -108,20 +106,4 @@ public class UserTokenServiceImpl implements UserTokenService {
} }
} }
@Override
public void doLog(HttpServletRequest request) {
LoginToken token = this.getToken();
String loginid = String.valueOf(token.getId());
Date now = new Date();
String path = request.getRequestURI().replace(request.getContextPath(), "");
String prefix = path.split("/")[1];
String content = JSON.toJSONString(request.getParameterMap());
String ip = ServletUtil.remoteIp(request);
String user_agent = request.getHeader("User-Agent");
String sql = "insert into fc_logs (type, loginid, prefix, path, ip, content, user_agent, create_time) values (?, ?, ?, ?, ?, ?, ?, ?)";
Object[] objs = new Object[]{LOG_TYPE, loginid, prefix, path, ip, content, user_agent, now};
jdbcTemplate.executeUpdate(sql, objs);
}
} }
...@@ -34,7 +34,6 @@ public class AdminLoginController { ...@@ -34,7 +34,6 @@ public class AdminLoginController {
} else { } else {
LoginToken token = tokenService.doLogin(username, password); LoginToken token = tokenService.doLogin(username, password);
if(token != null) { if(token != null) {
tokenService.doLog(request);
return Rjx.jsonOk().setData(token); return Rjx.jsonOk().setData(token);
} else { } else {
throw new XRException("用户名或密码错误"); throw new XRException("用户名或密码错误");
......
...@@ -43,7 +43,6 @@ public class MemberLoginController { ...@@ -43,7 +43,6 @@ public class MemberLoginController {
} else { } else {
LoginToken token = tokenService.doLogin(username, password); LoginToken token = tokenService.doLogin(username, password);
if(token != null) { if(token != null) {
tokenService.doLog(request);
return Rjx.jsonOk(); return Rjx.jsonOk();
} else { } else {
throw new XRException(messages.get("err.user_or_pwd")); throw new XRException(messages.get("err.user_or_pwd"));
......
...@@ -20,7 +20,6 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter { ...@@ -20,7 +20,6 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
@Override @Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception { public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
if(tokenService.isLogin()) { if(tokenService.isLogin()) {
tokenService.doLog(req);
return super.preHandle(req, resp, handler); return super.preHandle(req, resp, handler);
} else { } else {
String sessionid = null; String sessionid = null;
...@@ -33,7 +32,6 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter { ...@@ -33,7 +32,6 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
} }
} }
if(sessionid != null && tokenService.isLoginByToken(sessionid)) { if(sessionid != null && tokenService.isLoginByToken(sessionid)) {
tokenService.doLog(req);
return super.preHandle(req, resp, handler); return super.preHandle(req, resp, handler);
} }
throw new XRException("用户未登陆", 300); throw new XRException("用户未登陆", 300);
......
...@@ -20,7 +20,6 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter { ...@@ -20,7 +20,6 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
@Override @Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception { public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
if(tokenService.isLogin()) { if(tokenService.isLogin()) {
tokenService.doLog(req);
return super.preHandle(req, resp, handler); return super.preHandle(req, resp, handler);
} else { } else {
String sessionid = null; String sessionid = null;
...@@ -33,7 +32,6 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter { ...@@ -33,7 +32,6 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
} }
} }
if(sessionid != null && tokenService.isLoginByToken(sessionid)) { if(sessionid != null && tokenService.isLoginByToken(sessionid)) {
tokenService.doLog(req);
return super.preHandle(req, resp, handler); return super.preHandle(req, resp, handler);
} }
throw new XRException("用户未登陆", 300); throw new XRException("用户未登陆", 300);
......
...@@ -20,7 +20,6 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter { ...@@ -20,7 +20,6 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
@Override @Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception { public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
if(tokenService.isLogin()) { if(tokenService.isLogin()) {
tokenService.doLog(req);
return super.preHandle(req, resp, handler); return super.preHandle(req, resp, handler);
} else { } else {
String sessionid = null; String sessionid = null;
...@@ -33,7 +32,6 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter { ...@@ -33,7 +32,6 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
} }
} }
if(sessionid != null && tokenService.isLoginByToken(sessionid)) { if(sessionid != null && tokenService.isLoginByToken(sessionid)) {
tokenService.doLog(req);
return super.preHandle(req, resp, handler); return super.preHandle(req, resp, handler);
} }
throw new XRException("用户未登陆", 300); throw new XRException("用户未登陆", 300);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment