Commit 7f4e691e by wangli

修改

1 parent 704c2e2c
......@@ -22,7 +22,7 @@ public interface IResult {
* Get result code.
* @return result code
*/
Integer getCode();
String getCode();
/**
* Get result message.
......
......@@ -21,15 +21,14 @@ package com.alibaba.cloud.integration.common;
*/
public class Result<T> {
private Integer code;
private String code;
private String message;
private T data;
private T result;
public static <T> Result<T> success(T data) {
return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage(),
data);
return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage(), data);
}
public static <T> Result<T> success(String message, T data) {
......@@ -52,17 +51,17 @@ public class Result<T> {
public Result() {
}
public Result(Integer code, String message, T data) {
public Result(String code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
this.result = data;
}
public Integer getCode() {
public String getCode() {
return code;
}
public void setCode(Integer code) {
public void setCode(String code) {
this.code = code;
}
......@@ -75,19 +74,18 @@ public class Result<T> {
}
public T getData() {
return data;
return result;
}
public void setData(T data) {
this.data = data;
this.result = data;
}
public static <T> Result<T> instance(Integer code, String message, T data) {
public static <T> Result<T> instance(String code, String message, T data) {
Result<T> result = new Result<>();
result.setCode(code);
result.setMessage(message);
result.setData(data);
return result;
}
}
......@@ -25,30 +25,30 @@ public enum ResultEnum implements IResult {
/**
* return success result.
*/
SUCCESS(2001, "接口调用成功"),
SUCCESS("S001", "接口调用成功"),
/**
* return business common failed.
*/
COMMON_FAILED(2003, "接口调用失败");
COMMON_FAILED("F001", "接口调用失败");
private Integer code;
private String code;
private String message;
ResultEnum() {
}
ResultEnum(Integer code, String message) {
ResultEnum(String code, String message) {
this.code = code;
this.message = message;
}
@Override
public Integer getCode() {
public String getCode() {
return code;
}
public void setCode(Integer code) {
public void setCode(String code) {
this.code = code;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!