ResultErp.java
7.84 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
package com.huaheng.framework.web.domain;
import java.io.Serializable;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.huaheng.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 操作消息提醒
* @author Enzo Cotter
* @date 2020/6/11
*/
@ApiModel(
value = "接口返回对象",
description = "接口返回对象"
)
public class ResultErp<T> implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("成功标志")
private boolean success = true;
@ApiModelProperty("返回处理消息")
private String message = "";
@ApiModelProperty("返回代码")
private Integer code = 0;
@ApiModelProperty("返回数据对象")
private T result;
@ApiModelProperty("时间戳")
private long timestamp = System.currentTimeMillis();
@JsonIgnore
private String onlTable;
public ResultErp() {
}
public ResultErp(Integer code, String message) {
this.code = code;
this.message = message;
}
public ResultErp<T> success(String message) {
this.message = message;
this.code = 200;
this.success = true;
return this;
}
/** @deprecated */
@Deprecated
public static <T> ResultErp<T> ok() {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
return r;
}
/** @deprecated */
@Deprecated
public static <T> ResultErp<T> ok(String msg) {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
r.setMessage(msg);
return r;
}
/** @deprecated */
@Deprecated
public static <T> ResultErp<T> ok(T data) {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
r.setResult(data);
return r;
}
public static <T> ResultErp<T> OK() {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
return r;
}
/** @deprecated */
@Deprecated
public static <T> ResultErp<T> OK(String msg) {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
r.setMessage(msg);
r.setResult((T) msg);
return r;
}
public static <T> ResultErp<T> OK(T data) {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
r.setResult(data);
return r;
}
public static <T> ResultErp<T> OK(String msg, T data) {
ResultErp<T> r = new ResultErp();
r.setSuccess(true);
r.setCode(200);
r.setMessage(msg);
r.setResult(data);
return r;
}
public static <T> ResultErp<T> error(String msg, T data) {
ResultErp<T> r = new ResultErp();
r.setSuccess(false);
r.setCode(500);
r.setMessage(msg);
r.setResult(data);
return r;
}
public static <T> ResultErp<T> error(String msg) {
return error(500, msg);
}
public static <T> ResultErp<T> error(int code, String msg) {
ResultErp<T> r = new ResultErp();
r.setCode(code);
r.setMessage(msg);
r.setSuccess(false);
return r;
}
public ResultErp<T> error500(String message) {
this.message = message;
this.code = 500;
this.success = false;
return this;
}
public static <T> ResultErp<T> noauth(String msg) {
return error(510, msg);
}
public boolean isSuccess() {
return this.success;
}
public String getMessage() {
return this.message;
}
public Integer getCode() {
return this.code;
}
public T getResult() {
return this.result;
}
public long getTimestamp() {
return this.timestamp;
}
public String getOnlTable() {
return this.onlTable;
}
public void setSuccess(final boolean success) {
this.success = success;
}
public void setMessage(final String message) {
this.message = message;
}
public void setCode(final Integer code) {
this.code = code;
}
public void setResult(final T result) {
this.result = result;
}
public void setTimestamp(final long timestamp) {
this.timestamp = timestamp;
}
@JsonIgnore
public void setOnlTable(final String onlTable) {
this.onlTable = onlTable;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof Result)) {
return false;
} else {
ResultErp<?> other = (ResultErp)o;
if (!other.canEqual(this)) {
return false;
} else if (this.isSuccess() != other.isSuccess()) {
return false;
} else if (this.getTimestamp() != other.getTimestamp()) {
return false;
} else {
label64: {
Object this$code = this.getCode();
Object other$code = other.getCode();
if (this$code == null) {
if (other$code == null) {
break label64;
}
} else if (this$code.equals(other$code)) {
break label64;
}
return false;
}
label57: {
Object this$message = this.getMessage();
Object other$message = other.getMessage();
if (this$message == null) {
if (other$message == null) {
break label57;
}
} else if (this$message.equals(other$message)) {
break label57;
}
return false;
}
Object this$result = this.getResult();
Object other$result = other.getResult();
if (this$result == null) {
if (other$result != null) {
return false;
}
} else if (!this$result.equals(other$result)) {
return false;
}
Object this$onlTable = this.getOnlTable();
Object other$onlTable = other.getOnlTable();
if (this$onlTable == null) {
if (other$onlTable != null) {
return false;
}
} else if (!this$onlTable.equals(other$onlTable)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof Result;
}
public int hashCode() {
int result = 1;
result = result * 59 + (this.isSuccess() ? 79 : 97);
long $timestamp = this.getTimestamp();
result = result * 59 + (int)($timestamp >>> 32 ^ $timestamp);
Object $code = this.getCode();
result = result * 59 + ($code == null ? 43 : $code.hashCode());
Object $message = this.getMessage();
result = result * 59 + ($message == null ? 43 : $message.hashCode());
Object $result = this.getResult();
result = result * 59 + ($result == null ? 43 : $result.hashCode());
Object $onlTable = this.getOnlTable();
result = result * 59 + ($onlTable == null ? 43 : $onlTable.hashCode());
return result;
}
public String toString() {
return "Result(success=" + this.isSuccess() + ", message=" + this.getMessage() + ", code=" + this.getCode() + ", result=" + this.getResult() + ", timestamp=" + this.getTimestamp() + ", onlTable=" + this.getOnlTable() + ")";
}
}