修改session时间

master
zengwh 5 years ago
parent 5fc47425b6
commit 4e5f0d8148

@ -268,6 +268,10 @@ public class FontController {
if (cache == null) { if (cache == null) {
return Msg.fail("token已过期或不存在"); return Msg.fail("token已过期或不存在");
} }
//更新过期时间
Power_UserVo user = (Power_UserVo) cache.getValue();
String date = String.valueOf(DateUtils.getDate());
CacheManager.putCache(token,new Cache(date,user,TOKEN_EXPIRE_TIME));
}else{ }else{
return Msg.fail("token不能为空"); return Msg.fail("token不能为空");
} }

@ -7,8 +7,11 @@ import com.manage.service.cache.Cache;
import com.manage.service.cache.CacheManager; import com.manage.service.cache.CacheManager;
import com.manage.service.Power_UserService; import com.manage.service.Power_UserService;
import com.manage.util.Constant; import com.manage.util.Constant;
import com.manage.util.DateUtils;
import com.manage.vo.Power_UserVo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher; import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
@ -19,9 +22,12 @@ import javax.servlet.http.HttpServletResponse;
import java.util.Properties; import java.util.Properties;
public class LoginInterceptor implements HandlerInterceptor { public class LoginInterceptor implements HandlerInterceptor {
@Value("${TOKEN_EXPIRE_TIME}")
private long TOKEN_EXPIRE_TIME;
@Autowired @Autowired
Power_UserService powerUserService; Power_UserService powerUserService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
String ctx = request.getServletContext().getContextPath(); String ctx = request.getServletContext().getContextPath();
String url = request.getRequestURI(); String url = request.getRequestURI();
@ -46,6 +52,12 @@ public class LoginInterceptor implements HandlerInterceptor {
token = MD5.JM(Base64.decode(token)); token = MD5.JM(Base64.decode(token));
Cache cache = CacheManager.getCacheInfo(token); Cache cache = CacheManager.getCacheInfo(token);
if (cache != null) { if (cache != null) {
if(!"/getSessionRemainingTime".equals(parentUrl)) {
//更新过期时间
Power_UserVo user = (Power_UserVo) cache.getValue();
String date = String.valueOf(DateUtils.getDate());
CacheManager.putCache(token, new Cache(date, user, TOKEN_EXPIRE_TIME));
}
return true; return true;
} }
} }
@ -77,8 +89,9 @@ public class LoginInterceptor implements HandlerInterceptor {
String[] values = value.split(","); String[] values = value.split(",");
PathMatcher matcher = new AntPathMatcher(); PathMatcher matcher = new AntPathMatcher();
for(String v : values){ for(String v : values){
if(matcher.match(v,url)) if(matcher.match(v,url)) {
return true; return true;
}
} }
}else if(value.equals(url)){ }else if(value.equals(url)){
return true; return true;

@ -5,11 +5,11 @@ releaseRequest = /login,/logout,/services,/font,/refuse,/swagger-ui.html,/webjar
ajaxRequest = none ajaxRequest = none
#session过期时间 #session过期时间
TOKEN_EXPIRE_TIME = 1200000 TOKEN_EXPIRE_TIME = 3600000
##################################################服务器ip########################################################## ##################################################服务器ip##########################################################
#通用服务器IP与通用服务器端口 #通用服务器IP与通用服务器端口
SERVER_IP = localhost SERVER_IP = 192.168.1.101
SERVER_PORT = 8081 SERVER_PORT = 8081
#power权限系统ip #power权限系统ip

@ -1,5 +1,5 @@
jdbc.driver=com.mysql.jdbc.Driver jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://localhost\:3306/qfpower?useUnicode\=true&characterEncoding\=utf-8 jdbc.url=jdbc\:mysql\://192.168.1.3\:3306/qfpower?useUnicode\=true&characterEncoding\=utf-8
jdbc.username=root jdbc.username=root
jdbc.password=docus702 jdbc.password=docus702

Loading…
Cancel
Save