JsResult.java
1.15 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
package com.polysoft.nafmii.bean;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
public class JsResult {
public static final String SUCCESS = "0";
public static final String FAIL = "1";
@JSONField(name = "status")
protected String status;
@JSONField(name = "statusText")
protected String statusText;
@JSONField(name = "data")
protected Object data;
private JsResult() {
}
public JsResult(String status, String statusText, Object data) {
this.status = status;
this.statusText = statusText;
this.data = data;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
public static JsResult success(String statusText, Object data) {
return new JsResult(SUCCESS, statusText, data);
}
public static JsResult success(Object data) {
return success("success", data);
}
public static JsResult fail(String statusText, Object data) {
return new JsResult(FAIL, statusText, data);
}
public static JsResult fail(String statusText) {
return fail(statusText, null);
}
}