This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-argus-service/src/main/java/com/nis/restful/DefaultRestSuccessConverter.java
zhangdongxu 6cb083ebee 1、项目名称改为galaxy,并将项目代码中有关gk的目录改为galaxy;
2、接口返回参数中添加追踪状态码traceCode,用于查看服务处理日志,方便调试与定故障定位;
3、添加项目调试模式(isDebug参数),调用maat通用接口时,调式携带提交内容,生产过程为空;
2018-05-19 11:30:50 +08:00

63 lines
1.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @Title: DefaultRestSuccessConverter.java
* @Package com.nis.restful
* @Description: TODO(用一句话描述该文件做什么)
* @author darnell
* @date 2016年8月24日 下午4:24:22
* @version V1.0
*/
package com.nis.restful;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @ClassName: DefaultRestSuccessConverter
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (darnell)
* @date 2016年8月24日 下午4:24:22
* @version V1.0
*/
public class DefaultRestSuccessConverter implements RestConverter<Map> {
@SuppressWarnings("unchecked")
@Override
public Map convert(RestResult re) {
Map successMap = new LinkedHashMap();
successMap.put(RestConstants.REST_SERVICE_HTTP_STATUS, re.getStatus()
.value());
successMap.put(RestConstants.REST_SERVICE_BUSINESS_CODE, re.getBusinessCode()
.getValue());
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;
}
@Override
public String convertToJson(RestResult re) {
Map successMap = this.convert(re);
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(successMap);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
}