AmisMessage.java
1.61 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
package com.diligrp.assistant.shared.domain;
import com.diligrp.assistant.shared.ErrorCode;
/**
* @author jy
*/
public class AmisMessage<T> {
protected static final int CODE_SUCCESS = 0;
protected static final int CODE_FAILURE = ErrorCode.SYSTEM_UNKNOWN_ERROR;
protected static final String MSG_SUCCESS = "success";
private Integer status;
private String msg;
private T data;
public AmisMessage() {
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return this.data;
}
public void setData(T data) {
this.data = data;
}
public static AmisMessage<?> success() {
AmisMessage<?> result = new AmisMessage();
result.status = 0;
result.msg = "success";
return result;
}
public static <E> AmisMessage<E> success(E data) {
AmisMessage<E> result = new AmisMessage();
result.status = 0;
result.data = data;
result.msg = "success";
return result;
}
public static AmisMessage<?> failure(String message) {
AmisMessage<?> result = new AmisMessage();
result.status = 1000;
result.msg = message;
return result;
}
public static AmisMessage<?> failure(int code, String message) {
AmisMessage<?> result = new AmisMessage();
result.status = code;
result.msg = message;
return result;
}
}