Commit 06b438a9 by 刘宇峰

框架完善

1 parent c975a8b9
package com.glsx.plat.exception; package com.glsx.plat.exception;
import lombok.Getter; import lombok.Data;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.Serializable; import java.io.Serializable;
...@@ -9,9 +8,8 @@ import java.io.Serializable; ...@@ -9,9 +8,8 @@ import java.io.Serializable;
/** /**
* @author payu * @author payu
*/ */
@Setter
@Getter
@Slf4j @Slf4j
@Data
public class ServiceException extends RuntimeException implements Serializable { public class ServiceException extends RuntimeException implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -19,12 +17,15 @@ public class ServiceException extends RuntimeException implements Serializable { ...@@ -19,12 +17,15 @@ public class ServiceException extends RuntimeException implements Serializable {
private String msg; private String msg;
private String code; private String code;
public ServiceException(String code, String msg) {
super(msg);
this.code = code;
this.msg = msg;
}
public static ServiceException create(String code, String msg) { public static ServiceException create(String code, String msg) {
log.error("Service RuntimeException {} {}", code, msg); log.error("Service RuntimeException {} {}", code, msg);
ServiceException exception = new ServiceException(); return new ServiceException(code, msg);
exception.setCode(code);
exception.setMsg(msg);
return exception;
} }
} }
...@@ -68,10 +68,10 @@ public class RestTemplateRequestInterceptor implements ClientHttpRequestIntercep ...@@ -68,10 +68,10 @@ public class RestTemplateRequestInterceptor implements ClientHttpRequestIntercep
.resStatus(responseCopy.getRawStatusCode()) .resStatus(responseCopy.getRawStatusCode())
.build())); .build()));
// JSONObject resultJO = JSONUtil.parseObj(reqBody); JSONObject resultJO = JSONUtil.parseObj(resBody);
// if (!Objects.equals(SysConstants.ResultStatus.success.getCode(), resultJO.get("code"))) { if (!Objects.equals(SysConstants.ResultStatus.success.getCode(), resultJO.get("code"))) {
// throw ServiceException.create(resultJO.getStr("code"), resultJO.getStr("message")); throw ServiceException.create(resultJO.getStr("code"), resultJO.getStr("message"));
// } }
return responseCopy; return responseCopy;
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!