Helius
2020-12-15 2914588a65371a3ce43f678cde0a26cd8da26611
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
package com.matrix.core.pojo;
 
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.tools.InternationaUtil;
import com.matrix.core.tools.MdcUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.hive.plugin.message.StringUtil;
 
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author 姜友瑶
 * @description Ajax请求返回的结果对象
 * @data 2016-06-26
 */
public class    AjaxResult implements Serializable {
 
    private static final long serialVersionUID = 1L;
    /**
     * 请求成功
     */
    public static final String STATUS_SUCCESS = "200";
    /**
     * 请求未正常完成
     **/
    public static final String STATUS_FAIL = SystemErrorCode.SYSTEM_ERROR_MSG;
 
 
    /**
     * 用户登录状态失效
     */
    public static final String STATUS_LOGIN_INVALID = "700014";
 
 
    private String status;
    /**
     * 请求后跳转的页面
     */
    private String page;
    /**
     * info会被国际化工具先处理,找不到国际化资源则显示原始信息
     **/
    private String info;
    private Map<Object, Object> mapInfo = new HashMap<>();
    private List<?> rows;
    /**
     * 总记录数
     */
    private Integer total;
 
    private String requestId;
 
 
 
 
 
    public static AjaxResult buildSuccessInstance(String info) {
        return new AjaxResult(STATUS_SUCCESS, info);
    }
 
    public static AjaxResult buildSuccessInstance(List<?> rows, String info) {
        AjaxResult result= new AjaxResult(STATUS_SUCCESS, rows );
        result.setInfo(info);
        return  result;
    }
    public static AjaxResult buildSuccessInstance(List<?> rows, Integer total) {
        return new AjaxResult(STATUS_SUCCESS, rows, total);
    }
 
    public static AjaxResult buildSuccessInstance(List<?> rows) {
        return new AjaxResult(STATUS_SUCCESS, rows);
    }
 
    public static AjaxResult buildFailInstance(String info) {
        return new AjaxResult(STATUS_FAIL, info);
    }
 
 
    public AjaxResult() {
    }
 
    public AjaxResult(String status, List<?> rows, Integer total) {
        this.status = status;
        this.rows = rows;
        this.total = total;
        this.requestId= MdcUtil.getMdc();
    }
 
    /**
     * 设置简单信息,这是一个便捷的方法
     *
     * @param status
     * @param page
     * @param info
     */
    public AjaxResult(String status, List<?> rows) {
        this.status = status;
        this.rows = rows;
        this.requestId= MdcUtil.getMdc();
    }
 
    public AjaxResult(String status, String info, Object... param) {
        this.status = status;
        if(StringUtils.isNotBlank(info)) {
            this.info = InternationaUtil.getMesssge(info, param);
        }
        this.requestId= MdcUtil.getMdc();
    }
 
 
 
    public Integer getTotal() {
        return total;
    }
 
    public void setTotal(Integer total) {
        this.total = total;
    }
 
    public List<?> getRows() {
        return rows;
    }
 
    public void setRows(List<?> rows) {
        this.rows = rows;
    }
 
    public String getStatus() {
        return status;
    }
 
    public void setStatus(String status) {
        this.status = status;
    }
 
    public String getPage() {
        return page;
    }
 
    public void setPage(String page) {
        this.page = page;
    }
 
    public String getInfo() {
        return info;
    }
 
    public void setInfo(String info) {
        this.info = info;
    }
 
    public Map<Object, Object> getMapInfo() {
        return mapInfo;
    }
 
    public void setMapInfo(Map<Object, Object> mapInfo) {
        this.mapInfo = mapInfo;
    }
 
    public String getRequestId() {
        return requestId;
    }
 
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }
 
    /**
     * 在map对象中放置信息
     *
     * @param key
     * @param value 返回类型 void
     * @author:姜友瑶
     * @date 2016年9月11日
     */
    public void putInMap(Object key, Object value) {
        mapInfo.put(key, value);
    }
}