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
| package api.result;
|
|
| import org.apache.http.HttpStatus;
|
| import java.util.HashMap;
| import java.util.Map;
|
| /**
| * @program: wog
| * @description:
| * @author: YSS
| * @create: 2020-09-25 14:25
| **/
| public class Msg extends HashMap<String,Object> {
|
| public Msg() {
| put("code", 200);
| put("msg", "success");
| }
|
| public static Msg error() {
| return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
| }
|
| public static Msg error(String msg) {
| return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
| }
|
| public static Msg error(int code, String msg) {
| Msg msg1 = new Msg();
| msg1.put("code", code);
| msg1.put("msg", msg);
| return msg1;
| }
|
| public static Msg ok(String msg) {
| Msg r = new Msg();
| r.put("msg", msg);
| return r;
| }
|
| public static Msg ok(Map<String, Object> map) {
| Msg r = new Msg();
| r.putAll(map);
| return r;
| }
|
| public static Msg ok() {
| return new Msg();
| }
|
| public Msg put(String key, Object value) {
| super.put(key, value);
| return this;
| }
| }
|
|