package com.zhentao.vo;


import com.zhentao.commonstants.CommonConstants;
import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String msg;

    private T data;

    public static Result success() {
        Result result = new Result();
        result.setCode(CommonConstants.OK);
        result.setMsg(CommonConstants.SUCCESS);
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(CommonConstants.OK);
        result.setMsg(CommonConstants.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(201);
        result.setMsg("fail");
        return result;
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}