package com.jkcredit.invoice.util;

import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 上游数据封装实现类
 * @author mumuxigua
 */
@Builder
@ToString
@Accessors(chain = true)
@AllArgsConstructor
public class RespR<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    @Getter
    @Setter
    private int code = 0;

    @Getter
    @Setter
    private String msg = "success";


    @Getter
    @Setter
    private T data;

    public RespR() {
        super();
    }

    public RespR(T data) {
        super();
        this.data = data;
    }

    public RespR(T data, String msg) {
        super();
        if (data.equals(Boolean.FALSE)) {
            this.code = 1;
        }
        this.data = data;
        this.msg = msg;
    }

    public RespR(Throwable e) {
        super();
        this.msg = e.getMessage();
        this.code = 1;
    }
}
