package io.gisbi.config;

import java.util.HashMap;

public class ResponseResult extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public ResponseResult() {
    }


    public static ResponseResult error() {
        return error("操作失败");
    }

    public static ResponseResult success() {
        return success("操作成功");
    }

    public static ResponseResult error(String msg) {
        ResponseResult json = new ResponseResult();
        json.put((String)"code", "1");//错误
        json.put((String)"msg", msg);
        return json;
    }

    public static ResponseResult message(String code, String msg) {
        ResponseResult json = new ResponseResult();
        json.put((String)"code", code);
        json.put((String)"msg", msg);
        return json;
    }

    public static ResponseResult success(String msg) {
        ResponseResult json = new ResponseResult();
        json.put((String)"code", "0");//正常
        json.put((String)"msg", msg);
        return json;
    }

    public static ResponseResult successData(Object obj) {
        ResponseResult json = new ResponseResult();
        json.put((String)"code", "0");//正常
        json.put((String)"msg", "操作成功");
        json.put("data", obj);
        return json;
    }


    public ResponseResult put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
