|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+package com.chinaitop.depot.unissoft.model;
|
|
|
2
|
+
|
|
|
3
|
+import java.io.Serializable;
|
|
|
4
|
+
|
|
|
5
|
+//返回基类
|
|
|
6
|
+public class ResponseEntity<T> implements Serializable {
|
|
|
7
|
+
|
|
|
8
|
+ private static final long serialVersionUID = -2825436079063723409L;
|
|
|
9
|
+
|
|
|
10
|
+ //成功
|
|
|
11
|
+ private static final String OK = "200";
|
|
|
12
|
+ //失败
|
|
|
13
|
+ private static final String FAILED = "600";
|
|
|
14
|
+ private static final String BUSSINESS_FAILED = "550";
|
|
|
15
|
+ private static final String UNAUTHENTICATION = "401";
|
|
|
16
|
+
|
|
|
17
|
+ private String retCode;
|
|
|
18
|
+ private String message;
|
|
|
19
|
+ private T data;
|
|
|
20
|
+
|
|
|
21
|
+ public String getRetCode() {
|
|
|
22
|
+ return retCode;
|
|
|
23
|
+ }
|
|
|
24
|
+
|
|
|
25
|
+ public void setRetCode(String retCode) {
|
|
|
26
|
+ this.retCode = retCode;
|
|
|
27
|
+ }
|
|
|
28
|
+
|
|
|
29
|
+ public String getMessage() {
|
|
|
30
|
+ return message;
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ public void setMessage(String message) {
|
|
|
34
|
+ this.message = message;
|
|
|
35
|
+ }
|
|
|
36
|
+
|
|
|
37
|
+ public T getData() {
|
|
|
38
|
+ return data;
|
|
|
39
|
+ }
|
|
|
40
|
+
|
|
|
41
|
+ public void setData(T data) {
|
|
|
42
|
+ this.data = data;
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+ private static <T> ResponseEntity<T> buildResponse(String retCode, String message, T data){
|
|
|
46
|
+ ResponseEntity<T> responseEntity = new ResponseEntity<T>();
|
|
|
47
|
+ responseEntity.retCode = retCode;
|
|
|
48
|
+ responseEntity.message = message;
|
|
|
49
|
+ responseEntity.data = data;
|
|
|
50
|
+ return responseEntity;
|
|
|
51
|
+ }
|
|
|
52
|
+
|
|
|
53
|
+ public static <T> ResponseEntity<T> ok(){
|
|
|
54
|
+ return buildResponse(ResponseEntity.OK,"success",null);
|
|
|
55
|
+ }
|
|
|
56
|
+ public static <T> ResponseEntity<T> ok(T data){
|
|
|
57
|
+ return buildResponse(ResponseEntity.OK,"success",data);
|
|
|
58
|
+
|
|
|
59
|
+ }
|
|
|
60
|
+ public static <T> ResponseEntity<T> ok(String message, T data){
|
|
|
61
|
+ return buildResponse(ResponseEntity.OK,message,data);
|
|
|
62
|
+ }
|
|
|
63
|
+
|
|
|
64
|
+
|
|
|
65
|
+ public static <T> ResponseEntity<T> failed(String message){
|
|
|
66
|
+ return buildResponse(ResponseEntity.FAILED,message,null);
|
|
|
67
|
+ }
|
|
|
68
|
+
|
|
|
69
|
+ public static <T> ResponseEntity<T> businessFailed(String message){
|
|
|
70
|
+ return buildResponse(ResponseEntity.BUSSINESS_FAILED,message,null);
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ public static <T> ResponseEntity<T> unauthentication(String message){
|
|
|
74
|
+ return buildResponse(ResponseEntity.UNAUTHENTICATION,message,null);
|
|
|
75
|
+ }
|
|
|
76
|
+
|
|
|
77
|
+ private String state;
|
|
|
78
|
+ private String msg;
|
|
|
79
|
+
|
|
|
80
|
+ public String getState() {
|
|
|
81
|
+ return state;
|
|
|
82
|
+ }
|
|
|
83
|
+
|
|
|
84
|
+ public void setState(String state) {
|
|
|
85
|
+ this.state = state;
|
|
|
86
|
+ }
|
|
|
87
|
+
|
|
|
88
|
+ public String getMsg() {
|
|
|
89
|
+ return msg;
|
|
|
90
|
+ }
|
|
|
91
|
+
|
|
|
92
|
+ public void setMsg(String msg) {
|
|
|
93
|
+ this.msg = msg;
|
|
|
94
|
+ }
|
|
|
95
|
+}
|
|
|
96
|
+
|