public class R1 extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public R1() {
put("code", 0);
put("msg", "success");
}
public Integer getCode(){
Object code = get("code");
String s = String.valueOf(code);
return Integer.valueOf(s);
}
public <T> T getData(String key, TypeReference<T> tTypeReference){
Object data = this.get(key);
String s = JSON.toJSONString(data);
T t = JSON.parseObject(s, tTypeReference);
return t;
}
public static R1 error(int code, String msg) {
R1 r = new R1();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static R1 ok() {
return new R1();
}
public R1 put(String key, Object value) {
super.put(key, value);
return this;
}
}