Browse Source

RenException增加构造方法new RenException(int code,String msg)

dev_shibei_match
wangchao 6 years ago
parent
commit
8f79cf0fa7
  1. 13
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenException.java
  2. 2
      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;

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

@ -117,7 +117,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) {
//说明登录状态时效(超时) //说明登录状态时效(超时)

Loading…
Cancel
Save