package com.xydl.cac.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public class Response<T> implements Serializable {
    private boolean success;
    private String errorMsg;
    private String warnMsg;
    private T data;

    public Response(T data) {
        this.success = true;
        this.data = data;
    }

    public Response(boolean success, String message) {
        this.success = success;
        this.errorMsg = message;
    }

    public static <T> Response<T> success(T data) {
        return new Response<>(data);
    }

    public static <T> Response<T> fail(String message) {
        return new Response<>(false, message);
    }
}
