RestResult.java
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.irrigation.icl.entity;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonValue;
import com.irrigation.icl.enums.ResultEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @param <T>
* @author zhangchuanxi
* 公共返回类
* @version 1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "RestResult")
public class RestResult<T> implements Serializable {
@ApiModelProperty(value = "返回编码类型", example = "200", allowableValues = "200,400")
private int code;
@ApiModelProperty(value = "返回提示消息", example = "成功")
private String message;
@ApiModelProperty(value = "返回请求数据对象")
private T data;
public String getMessage() {
return message != null ? message : ResultEnum.getCode(code).getMessage();
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
}