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
package com.haomostudio.SeekTruthBackend.common;
import java.util.HashMap;
import java.util.Map;
public class Resp {
public static final int SUCCESS = 0;
public static final int FAIL = -1;
public static final int WARN = 1;
public static final String CODE = "code";
public static final String MSG = "message";
public static final String FIELDS = "fields";
public static Map<String, Object> succ(String message) {
return result(SUCCESS, message, null);
}
public static Map<String, Object> succ(String message, Object fields) {
return result(SUCCESS, message, fields);
}
public static Map<String, Object> fail(String message) {
return result(FAIL, message, null);
}
public static Map<String, Object> warn(String message) {
return result(WARN, message, null);
}
public static Map<String, Object> fail(int code, String message) {
return result(code, message, null);
}
public static Map<String, Object> fail(String message, Object fields) {
return result(FAIL, message, fields);
}
public static Map<String, Object> result(int code, String message, Object fields) {
Map<String, Object> map = new HashMap<>();
map.put(CODE, code);
map.put(MSG, message);
map.put(FIELDS, fields);
return map;
}
}