Commit 7f4e691e by wangli

修改

1 parent 704c2e2c
...@@ -22,7 +22,7 @@ public interface IResult { ...@@ -22,7 +22,7 @@ public interface IResult {
* Get result code. * Get result code.
* @return result code * @return result code
*/ */
Integer getCode(); String getCode();
/** /**
* Get result message. * Get result message.
......
...@@ -21,15 +21,14 @@ package com.alibaba.cloud.integration.common; ...@@ -21,15 +21,14 @@ package com.alibaba.cloud.integration.common;
*/ */
public class Result<T> { public class Result<T> {
private Integer code; private String code;
private String message; private String message;
private T data; private T result;
public static <T> Result<T> success(T data) { public static <T> Result<T> success(T data) {
return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage(), return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage(), data);
data);
} }
public static <T> Result<T> success(String message, T data) { public static <T> Result<T> success(String message, T data) {
...@@ -52,17 +51,17 @@ public class Result<T> { ...@@ -52,17 +51,17 @@ public class Result<T> {
public Result() { public Result() {
} }
public Result(Integer code, String message, T data) { public Result(String code, String message, T data) {
this.code = code; this.code = code;
this.message = message; this.message = message;
this.data = data; this.result = data;
} }
public Integer getCode() { public String getCode() {
return code; return code;
} }
public void setCode(Integer code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
...@@ -75,19 +74,18 @@ public class Result<T> { ...@@ -75,19 +74,18 @@ public class Result<T> {
} }
public T getData() { public T getData() {
return data; return result;
} }
public void setData(T data) { 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<T> result = new Result<>();
result.setCode(code); result.setCode(code);
result.setMessage(message); result.setMessage(message);
result.setData(data); result.setData(data);
return result; return result;
} }
} }
...@@ -25,30 +25,30 @@ public enum ResultEnum implements IResult { ...@@ -25,30 +25,30 @@ public enum ResultEnum implements IResult {
/** /**
* return success result. * return success result.
*/ */
SUCCESS(2001, "接口调用成功"), SUCCESS("S001", "接口调用成功"),
/** /**
* return business common failed. * return business common failed.
*/ */
COMMON_FAILED(2003, "接口调用失败"); COMMON_FAILED("F001", "接口调用失败");
private Integer code; private String code;
private String message; private String message;
ResultEnum() { ResultEnum() {
} }
ResultEnum(Integer code, String message) { ResultEnum(String code, String message) {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
@Override @Override
public Integer getCode() { public String getCode() {
return code; return code;
} }
public void setCode(Integer code) { public void setCode(String code) {
this.code = 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!