package com.nbclass.vo.base;

import com.nbclass.util.CoreConst;

import lombok.Data;

import java.util.Map;

/**
 * 返回数据对象
 * @author Leon
 * @datetime 2020年1月10日 下午2:12:08
 */
@Data
public class Result {

    private int ret;
    private String msg;
    private Object data;
    private Map<String,Object> map;

    public Result() {
    }

    public Result(int ret, String msg, Object data) {
        this.ret = ret;
        this.msg = msg;
        this.data = data;
    }

    public static Result success() {
        return new Result(CoreConst.STATUS_SUCCESS, null, null);
    }
    
    public static Result success(Object data) {
        return new Result(CoreConst.STATUS_SUCCESS, null, data);
    }
    public static Result success(Map<String,Object> map) {
        return new Result(CoreConst.STATUS_SUCCESS, null, map);
    }

    public static Result success(String msg, Object data) {
        return new Result(CoreConst.STATUS_SUCCESS, msg, data);
    }

    public static Result error() {
    	return new Result(CoreConst.STATUS_ERROR, null, null);
    }
    
    public static Result error(String msg) {
        return new Result(CoreConst.STATUS_ERROR, msg, null);
    }

    public static Result error(int code, String msg) {
        return new Result(code, msg, null);
    }
    
}
