package com.heyu.api.data.utils;

import lombok.Data;

@Data
public class ApiR<T> {
    /**
     * 业务数据放在
     */
    private T data;

    /**
     * 是否是true
     */
    private boolean success;

    /**
     * 错误信息
     */
    private String errorMsg;

    /***
     * 是否收钱
     */
    private boolean receiveMoney = false;

    public static ApiR error(String error) {
        ApiR apiR = new ApiR();
        apiR.errorMsg = error;
        apiR.success = false;
        apiR.receiveMoney = false;

        return apiR;
    }

    public static ApiR setData(Object resp) {
        ApiR apiR = new ApiR();
        apiR.data = resp;
        apiR.success = true;
        return apiR;
    }

    public ApiR setReceiveMoney(boolean receiveMoney) {
        this.receiveMoney = receiveMoney;
        return this;
    }


}
