package top.imwork.commons.core.pojo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
 * Copyright (C), 2015-2025
 * FileName: ApiResponse
 * Author<作者姓名>:   stars
 * CreateTime<创建时间>:   2025/12/15 16:03
 * UpdateTime<修改时间>:   2025/12/15 16:03
 * Description〈功能简述〉: 用于文件上传响应
 * History<历史描述>:
 * Since<版本号>: 1.0.0
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ApiResponse<T> {
    private boolean success;
    private String message;
    private T data;
    private long timestamp;

    public static <T> ApiResponse<T> success(T data) {
        return ApiResponse.<T>builder()
                .success(true)
                .message("success")
                .data(data)
                .timestamp(System.currentTimeMillis())
                .build();
    }

    public static <T> ApiResponse<T> error(String message) {
        return ApiResponse.<T>builder()
                .success(false)
                .message(message)
                .data(null)
                .timestamp(System.currentTimeMillis())
                .build();
    }
}