package com.youchain.exception.handler;

import lombok.Data;

@Data
public class ApiResult {
    private Object data;//数据
    private String message;//内容
    private int status;//编码



    public static ApiResult fail() {

        return result(400, "操作失败!", null);
    }

    public static ApiResult fail(int code,String msg, Object data) {
        return result(code, msg, data);
    }

    public static ApiResult success() {
        return result(200, "操作成功!", null);
    }

    public static ApiResult success(Object data) {
        return result(200, "操作成功!", data);
    }

    public static ApiResult success(String msg, Object data) {
            return result(200, msg, data);
    }


    public static ApiResult result(int status, String message, Object data) {
        ApiResult rs = new ApiResult();
        rs.setStatus(status);
        rs.setMessage(message);
        rs.setData(data);
        return rs;
    }
}
