package cn.iocoder.yudao.framework.common.pojo;

import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import lombok.Data;

/**
 * 通用返回
 *
 * @param <T> 数据泛型
 */
@Data
public class StoreResult<T> {

    /**
     * 错误码
     *
     * @see ErrorCode#getCode()
     */
    private Integer statusCode;
    /**
     * 返回数据
     */
    private T data;
    /**
     * 错误提示，用户可阅读
     *
     * @see ErrorCode#getMsg() ()
     */
    private String message;

    private Boolean success;


    public static <T> StoreResult<T> success(T data) {
        StoreResult<T> result = new StoreResult<>();
        result.statusCode = 200;
        result.data = data;
        result.message = "操作成功";
        result.success = true;
        return result;
    }

    public static <T> StoreResult<T> fail(String message) {
        StoreResult<T> result =new StoreResult<>();
        result.statusCode = 300;
        result.message = message;
        result.success = false;
        return result;
    }








}
