|
@@ -6,6 +6,7 @@ import lombok.Data;
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
|
/**
|
|
|
* 通用返回类
|
|
@@ -25,7 +26,7 @@ public class Result<T> implements Serializable {
|
|
|
/**
|
|
|
* 处理状态:0: 成功, 1: 失败
|
|
|
*/
|
|
|
- @ApiModelProperty(value = "处理状态:0: 成功, 1: 失败", name = "code")
|
|
|
+ @ApiModelProperty(value = "处理状态:0: 成功, -1: 失败", name = "code")
|
|
|
private int code;
|
|
|
/**
|
|
|
* 消息
|
|
@@ -37,6 +38,9 @@ public class Result<T> implements Serializable {
|
|
|
*/
|
|
|
@ApiModelProperty(value = "返回数据", name = "data")
|
|
|
private T data;
|
|
|
+
|
|
|
+ @ApiModelProperty(value = "时间戳", name = "timestamp")
|
|
|
+ private LocalDateTime timestamp;
|
|
|
/**
|
|
|
* 处理成功,并返回数据
|
|
|
*
|
|
@@ -44,7 +48,7 @@ public class Result<T> implements Serializable {
|
|
|
* @return data
|
|
|
*/
|
|
|
public static Result success(Object data) {
|
|
|
- return new Result(CODE_SUCCESS, SUCCESS_MSG, data);
|
|
|
+ return new Result(CODE_SUCCESS, SUCCESS_MSG, data, LocalDateTime.now());
|
|
|
}
|
|
|
/**
|
|
|
* 处理成功
|
|
@@ -52,7 +56,7 @@ public class Result<T> implements Serializable {
|
|
|
* @return data
|
|
|
*/
|
|
|
public static Result success() {
|
|
|
- return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP);
|
|
|
+ return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP, LocalDateTime.now());
|
|
|
}
|
|
|
/**
|
|
|
* 处理成功
|
|
@@ -61,7 +65,7 @@ public class Result<T> implements Serializable {
|
|
|
* @return data
|
|
|
*/
|
|
|
public static Result success(String msg) {
|
|
|
- return new Result(CODE_SUCCESS, msg, NOOP);
|
|
|
+ return new Result(CODE_SUCCESS, msg, NOOP, LocalDateTime.now());
|
|
|
}
|
|
|
/**
|
|
|
* 处理成功
|
|
@@ -71,7 +75,7 @@ public class Result<T> implements Serializable {
|
|
|
* @return data
|
|
|
*/
|
|
|
public static Result success(String msg, Object data) {
|
|
|
- return new Result(CODE_SUCCESS, msg, data);
|
|
|
+ return new Result(CODE_SUCCESS, msg, data, LocalDateTime.now());
|
|
|
}
|
|
|
/**
|
|
|
* 处理失败,并返回数据(一般为错误信息)
|
|
@@ -81,7 +85,7 @@ public class Result<T> implements Serializable {
|
|
|
* @return data
|
|
|
*/
|
|
|
public static Result failure(int code, String msg) {
|
|
|
- return new Result(code, msg, NOOP);
|
|
|
+ return new Result(code, msg, NOOP , LocalDateTime.now());
|
|
|
}
|
|
|
/**
|
|
|
* 处理失败
|
|
@@ -96,6 +100,6 @@ public class Result<T> implements Serializable {
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
return "JsonResult [code=" + code + ", msg=" + msg + ", data="
|
|
|
- + data + "]";
|
|
|
+ + data + ", timestamp="+ timestamp + "]";
|
|
|
}
|
|
|
}
|