/**
 * 统一接口响应体。
 *
 * @param code    业务状态码
 * @param message 提示信息
 * @param data    返回数据
 */
package com.hertz.common.api;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public record ApiResponse<T>(int code, String message, T data) {
  public static <T> ApiResponse<T> ok(T data) {
    return new ApiResponse<>(0, "ok", data);
  }

  public static ApiResponse<Void> ok() {
    return new ApiResponse<>(0, "ok", null);
  }

  public static <T> ApiResponse<T> fail(int code, String message) {
    return new ApiResponse<>(code, message, null);
  }
}

