package org.springblade.openapi.track.pojo.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springblade.openapi.track.constant.TrackConstant;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author bfhuange
 * @since 2024/12/16
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Api4TrackResultVO<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
     *  响应代码。200为正确
     */
    private Integer state;
    /**
     *  对应的提示信息
     */
    private String message;
    /**
     *  数据
     */
    private T data;

    public Api4TrackResultVO(Integer state, T data) {
        this.state = state;
        this.data = data;
    }

    public static <T> Api4TrackResultVO<T> success() {
        return Api4TrackResultVO.success(null);
    }

    public static <T> Api4TrackResultVO<T> fail(String message) {
        return new Api4TrackResultVO<>(TrackConstant.FAIL_CODE, message, null);
    }

    public static <T> Api4TrackResultVO<T> success(T data) {
        return new Api4TrackResultVO<>(TrackConstant.SUCCESS_CODE, data);
    }
}
