RopResponse.java
2.52 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.glsk.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(
description = "响应信息"
)
public class RopResponse<T> {
private static final String SUCCESS_CODE = "0";
private static final String FAILED_CODE = "-1";
@ApiModelProperty(
name = "code",
notes = "响应状态(0:成功;1:失败)",
dataType = "string",
required = true,
example = "0"
)
private String code;
@ApiModelProperty(
name = "errId",
notes = "错误码",
dataType = "string",
required = true
)
private String errId;
@ApiModelProperty(
name = "message",
notes = "错误描述",
dataType = "string",
example = "成功"
)
private String message;
@ApiModelProperty(
name = "data",
notes = "成功返回数据",
dataType = "object"
)
private T data;
public RopResponse() {
}
public String getCode() {
return this.code;
}
public RopResponse<T> setCode(String code) {
this.code = code;
return this;
}
public String getMessage() {
return this.message;
}
public RopResponse<T> setMessage(String message) {
this.message = message;
return this;
}
public T getData() {
return this.data;
}
public RopResponse<T> setData(T data) {
this.data = data;
return this;
}
public String getErrId() {
return this.errId;
}
public RopResponse<T> setErrId(String errId) {
this.errId = errId;
return this;
}
public static <T> RopResponse<T> error(String message) {
return (new RopResponse()).setCode("-1").setMessage(message);
}
public static <T> RopResponse<T> error(String errId, String message) {
return (new RopResponse()).setCode("-1").setErrId(errId).setMessage(message);
}
public static <T> RopResponse<T> error(String errId, String message, T data) {
return (new RopResponse()).setCode("-1").setErrId(errId).setMessage(message).setData(data);
}
public static <T> RopResponse<T> success(T data) {
return (new RopResponse()).setCode("0").setData(data).setMessage("调用服务成功!");
}
public String toString() {
return "RopResponse [code=" + this.code + ", errId=" + this.errId + ", message=" + this.message + ", data=" + this.data + "]";
}
}