package org.dromara.ai.model;

public class ApiResult<T> {
    private boolean success;
    private String message;
    private String code;
    private T data;

    public static <T> ApiResult<T> ok(T data) {
        ApiResult<T> r = new ApiResult<>();
        r.success = true;
        r.data = data;
        return r;
    }

    public static <T> ApiResult<T> fail(String code, String message) {
        ApiResult<T> r = new ApiResult<>();
        r.success = false;
        r.code = code;
        r.message = message;
        return r;
    }

    public boolean isSuccess() {
        return success;
    }

    public String getMessage() {
        return message;
    }

    public String getCode() {
        return code;
    }

    public T getData() {
        return data;
    }

    public ApiResult<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public ApiResult<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    public ApiResult<T> setCode(String code) {
        this.code = code;
        return this;
    }

    public ApiResult<T> setData(T data) {
        this.data = data;
        return this;
    }
}

