JsonResult.java
4.31 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
package com.qgutech.common;
/**
* @author xxx
* @date 2024/12/19 9:58
* @description
*/
public class JsonResult<T> {
private boolean success = true;
private T data;
private String msg;
private String errCode;
public JsonResult() {
}
public JsonResult(boolean success, String msg) {
this.success = success;
this.msg = msg;
}
public JsonResult(boolean success, String msg, T data) {
this.success = success;
this.msg = msg;
this.data = data;
}
public JsonResult(boolean success, String errCode, String msg, T data) {
this.success = success;
this.errCode = errCode;
this.msg = msg;
this.data = data;
}
public static JsonResult ok() {
return new JsonResult();
}
public static JsonResult ok(String msg) {
return new JsonResult(true, msg);
}
public static <T> JsonResult ok(String msg, T data) {
return new JsonResult(true, msg, data);
}
public static JsonResult error() {
return new JsonResult(false, (String)null);
}
public static JsonResult error(String msg) {
return new JsonResult(false, msg);
}
public static <T> JsonResult error(String errCode, String msg) {
return new JsonResult(false, errCode, msg);
}
public boolean isSuccess() {
return this.success;
}
public T getData() {
return this.data;
}
public String getMsg() {
return this.msg;
}
public String getErrCode() {
return this.errCode;
}
public void setSuccess(final boolean success) {
this.success = success;
}
public void setData(final T data) {
this.data = data;
}
public void setMsg(final String msg) {
this.msg = msg;
}
public void setErrCode(final String errCode) {
this.errCode = errCode;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof JsonResult)) {
return false;
} else {
JsonResult<?> other = (JsonResult)o;
if (!other.canEqual(this)) {
return false;
} else if (this.isSuccess() != other.isSuccess()) {
return false;
} else {
label49: {
Object this$data = this.getData();
Object other$data = other.getData();
if (this$data == null) {
if (other$data == null) {
break label49;
}
} else if (this$data.equals(other$data)) {
break label49;
}
return false;
}
Object this$msg = this.getMsg();
Object other$msg = other.getMsg();
if (this$msg == null) {
if (other$msg != null) {
return false;
}
} else if (!this$msg.equals(other$msg)) {
return false;
}
Object this$errCode = this.getErrCode();
Object other$errCode = other.getErrCode();
if (this$errCode == null) {
if (other$errCode != null) {
return false;
}
} else if (!this$errCode.equals(other$errCode)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof JsonResult;
}
public int hashCode() {
int result = 1;
result = result * 59 + (this.isSuccess() ? 79 : 97);
Object $data = this.getData();
result = result * 59 + ($data == null ? 43 : $data.hashCode());
Object $msg = this.getMsg();
result = result * 59 + ($msg == null ? 43 : $msg.hashCode());
Object $errCode = this.getErrCode();
result = result * 59 + ($errCode == null ? 43 : $errCode.hashCode());
return result;
}
public String toString() {
return "JsonResult(success=" + this.isSuccess() + ", data=" + this.getData() + ", msg=" + this.getMsg() + ", errCode=" + this.getErrCode() + ")";
}
}