package com.pannk.mms.common.base;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

/**
 * Created by wolf on 20-11-2.
 */
@Slf4j
@Data
public class Result extends HashMap<String, Object> {

    public Result() {
        put(Constant.CODE, 0);
        put(Constant.MESSAGE, Constant.SUCCESS);
    }

    public static Result success() {
        return new Result();
    }

    public static Result error(int code, String msg) {
        Result result = new Result();
        result.put(Constant.CODE, code);
        result.put(Constant.MESSAGE, msg);
        return result;
    }

    public static Result error(String msg) {
        return error(1, msg);
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.put(Constant.DATA, data);
        return result;
    }
}
