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
  | package com.xzx.gc.common.utils; 
 |    
 |  import org.apache.http.HttpStatus; 
 |    
 |  import java.util.HashMap; 
 |  import java.util.Map; 
 |    
 |  /** 
 |   * 返回数据 
 |   */ 
 |  public class MstRes extends HashMap<String, Object> { 
 |      private static final long serialVersionUID = 1L; 
 |    
 |    
 |      public MstRes() { 
 |          put("code", 0); 
 |          put("msg", "success"); 
 |      } 
 |    
 |      public static MstRes error() { 
 |          return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员"); 
 |      } 
 |    
 |      public static MstRes error(String msg) { 
 |          return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg); 
 |      } 
 |    
 |      public static MstRes error(int code, String msg) { 
 |          MstRes r = new MstRes(); 
 |          r.put("code", code); 
 |          r.put("msg", msg); 
 |          return r; 
 |      } 
 |    
 |      public static MstRes ok(String msg) { 
 |          MstRes r = new MstRes(); 
 |          r.put("msg", msg); 
 |          return r; 
 |      } 
 |    
 |      public static MstRes ok(Map<String, Object> map) { 
 |          MstRes r = new MstRes(); 
 |          r.putAll(map); 
 |          return r; 
 |      } 
 |    
 |      public static MstRes ok() { 
 |          return new MstRes(); 
 |      } 
 |    
 |      @Override 
 |      public MstRes put(String key, Object value) { 
 |          super.put(key, value); 
 |          return this; 
 |      } 
 |  } 
 |  
  |