All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pub.codex.common.models.R Maven / Gradle / Ivy

package pub.codex.common.models;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap {
    private static final long serialVersionUID = 1L;

    public R() {
        put("code", "0000");
        put("msg", "successful");
    }

    public static R error(String code, String msg) {
        R r = new R();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static R error() {
        return error("9999", "failed");
    }

    public static R error(String msg) {
        return error("9999", msg);
    }

    public static R ok() {
        return new R();
    }

    public static R ok(String msg) {
        R r = new R();
        r.put("msg", msg);
        return r;
    }

    public static R ok(Map map) {
        R r = new R();
        r.putAll(map);
        return r;
    }

    public R data(Object value) {
        super.put("data", value);
        return this;
    }

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy