Browse Source

Merge branches 'dev1.0' and 'dev1.0-resiguide' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev1.0-resiguide

dev_shibei_match
sunyuchao 6 years ago
parent
commit
74a39bf6dd
  1. 13
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenException.java
  2. 8
      epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java

13
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenException.java

@ -10,6 +10,7 @@ package com.epmet.commons.tools.exception;
import com.epmet.commons.tools.utils.MessageUtils; import com.epmet.commons.tools.utils.MessageUtils;
import org.apache.commons.lang3.StringUtils;
/** /**
* 自定义异常 * 自定义异常
@ -42,9 +43,19 @@ public class RenException extends RuntimeException {
public RenException(int code, Throwable e, String... params) { public RenException(int code, Throwable e, String... params) {
super(e); super(e);
this.code = code; this.code = code;
this.msg = MessageUtils.getMessage(code, params);
}
public RenException(int code, String msg){
this.code = code;
if(StringUtils.isBlank(msg)){
this.msg = MessageUtils.getMessage(code, msg);
}else{
this.msg = msg;
}
} }
public RenException(String msg) { public RenException(String msg) {
super(msg); super(msg);
this.code = ErrorCode.INTERNAL_SERVER_ERROR; this.code = ErrorCode.INTERNAL_SERVER_ERROR;

8
epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java

@ -86,8 +86,6 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
logger.info("params token:" + token); logger.info("params token:" + token);
} }
if (StringUtils.isBlank(token)) { if (StringUtils.isBlank(token)) {
//return chain.filter(exchange);
//throw new RenException(com.epmet.common.token.enums.ErrorCode.ERR10005.getCode(), com.epmet.common.token.enums.ErrorCode.ERR10005.getMsg());
return response(exchange,new Result<>().error(ErrorCode.ERR10005.getCode(),ErrorCode.ERR10005.getMsg())); return response(exchange,new Result<>().error(ErrorCode.ERR10005.getCode(),ErrorCode.ERR10005.getMsg()));
} }
try { try {
@ -117,7 +115,7 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
String app = (String) claims.get("app"); String app = (String) claims.get("app");
String client = (String) claims.get("client"); String client = (String) claims.get("client");
String userId = (String) claims.get("userId"); String userId = (String) claims.get("userId");
//查询Redis,如果没数据,则保持用户信息到Redis //查询Redis
TokenDto tokenDto = cpUserDetailRedis.get(app, client, userId); TokenDto tokenDto = cpUserDetailRedis.get(app, client, userId);
if (null == tokenDto) { if (null == tokenDto) {
//说明登录状态时效(超时) //说明登录状态时效(超时)
@ -133,9 +131,7 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
} }
} }
//过期时间,不延期
//long expire = (claims.getExpiration().getTime() - System.currentTimeMillis()) / 1000;
//cpUserDetailRedis.set(tokenDto, expire);
return tokenDto; return tokenDto;
} }

Loading…
Cancel
Save