package com.storlead.framework.common.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @program: sp-sales
 * @description:
 * @author: chenkq
 * @create: 2024-03-17 11:26
 */

@Data
public class FeignResult<T> implements Serializable{
    private static final long serialVersionUID = 8225645185075835261L;

    /**
     * 是否处理成功
     */
    private boolean isSuccess;
    /**
     * 状态码, 默认1000是成功
     */
    protected int code;
    /**
     * 响应信息, 来说明响应情况
     */
    protected String msg;
    /**
     * 响应的具体数据
     */
    private T data;

    public FeignResult() {
        this.isSuccess = true;
        this.code = 200;
        this.msg = "成功";
        this.data = null;
    }

    public FeignResult(int code,String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> FeignResult<T> failure(String msg) {
        return new FeignResult<>(0,msg, null);
    }

    public static <T> FeignResult<T> success(String msg) {
        return new FeignResult<>(0,msg, null);
    }
}
