1、项目名称改为galaxy,并将项目代码中有关gk的目录改为galaxy;

2、接口返回参数中添加追踪状态码traceCode,用于查看服务处理日志,方便调试与定故障定位;
3、添加项目调试模式(isDebug参数),调用maat通用接口时,调式携带提交内容,生产过程为空;
This commit is contained in:
zhangdongxu
2018-05-19 11:30:50 +08:00
parent d825c96145
commit 6cb083ebee
32 changed files with 327 additions and 322 deletions

View File

@@ -24,6 +24,7 @@ public class DefaultRestErrorConverter implements RestConverter<Map> {
errorMap.put(RestConstants.REST_SERVICE_REASON, re.getBusinessCode()
.getErrorReason());
errorMap.put(RestConstants.REST_SERVICE_MSG, re.getMsg());
errorMap.put(RestConstants.TRACE_CODE, re.getTraceCode());
errorMap.put(RestConstants.REST_SERVICE_URI, re.getFromUri());
if(re.getActiveSys() != null){
@@ -32,7 +33,7 @@ public class DefaultRestErrorConverter implements RestConverter<Map> {
if(re.getLogSource() != null){
errorMap.put(RestConstants.REST_SERVICE_LOG_SOURCE, re.getLogSource());
}
return errorMap;
}

View File

@@ -63,6 +63,7 @@ public class DefaultRestErrorResolver implements RestErrorResolver,InitializingB
}else {
error.setFromUri("unknow url");
}
error.setTraceCode(((RestServiceException) ex).getTraceCode());
return error;
}

View File

@@ -36,8 +36,9 @@ public class DefaultRestSuccessConverter implements RestConverter<Map> {
successMap.put(RestConstants.REST_SERVICE_REASON, re.getBusinessCode()
.getErrorReason());
successMap.put(RestConstants.REST_SERVICE_MSG, re.getMsg());
successMap.put(RestConstants.TRACE_CODE, re.getTraceCode());
successMap.put(RestConstants.REST_SERVICE_URI, re.getFromUri());
return successMap;
}

View File

@@ -21,6 +21,8 @@ public class RestConstants {
public static final String REST_SERVICE_LOG_SOURCE = "logSource";
public static final String TRACE_CODE = "traceCode";
//暂时4个
/**

View File

@@ -50,11 +50,16 @@ public class RestResult {
*/
private String logSource;
/**
* 追踪状态码
*/
private String traceCode;
public RestResult(){
}
public RestResult(HttpStatus status, RestBusinessCode businessCode, String msg,String fromUri,String activeSys,String fromSign) {
public RestResult(HttpStatus status, RestBusinessCode businessCode, String msg,String fromUri,String activeSys,String fromSign,String traceCode) {
super();
this.status = status;
this.businessCode = businessCode;
@@ -62,6 +67,7 @@ public class RestResult {
this.fromUri = fromUri;
this.activeSys=activeSys;
this.logSource=logSource;
this.traceCode=traceCode;
}
@@ -152,6 +158,14 @@ public class RestResult {
this.data = data;
}
public String getTraceCode() {
return traceCode;
}
public void setTraceCode(String traceCode) {
this.traceCode = traceCode;
}
public String toString() {
return new StringBuilder().append("HttpStatus:").append(getStatus().value())
.append(" errorcode:")

View File

@@ -12,6 +12,7 @@ public class RestServiceException extends RuntimeException{
private String activeSys;
private String traceCode;
/**
*
*/
@@ -29,6 +30,7 @@ public class RestServiceException extends RuntimeException{
public RestServiceException(SaveRequestLogThread thread,long time,String message) {
super(message);
this.errorCode = 998; //未知错误
this.traceCode = thread.getTraceCode();
thread.setConsumerTime(time);
thread.setBusinessCode(this.getErrorCode());
if(StringUtils.isEmpty(thread.getExceptionInfo()))
@@ -43,6 +45,7 @@ public class RestServiceException extends RuntimeException{
public RestServiceException(SaveRequestLogThread thread,long time,String message,int errorCode) {
super(message);
this.errorCode = errorCode;
this.traceCode = thread.getTraceCode();
thread.setConsumerTime(time);
thread.setBusinessCode(this.getErrorCode());
if(StringUtils.isEmpty(thread.getExceptionInfo()))
@@ -71,6 +74,13 @@ public class RestServiceException extends RuntimeException{
public void setActiveSys(String activeSys) {
this.activeSys = activeSys;
}
public String getTraceCode() {
return traceCode;
}
public void setTraceCode(String traceCode) {
this.traceCode = traceCode;
}
}

View File

@@ -58,7 +58,7 @@ public class SwaggerConfig {
"V1.0",
"doufenghu@iie.ac.cn",
"My Apps API Licence Type",
"http://127.0.0.1:8080/gk/swagger/");
"http://127.0.0.1:8080/galaxy/swagger/");
return apiInfo;
}
}