CoolFace
Apppublic

sakthivikram/geo-location

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
ApiResponse.java46 linesDownload Raw Back to dto
1package com.georeport.dto;2 3import lombok.*;4 5/**6 * Generic API response wrapper.7 */8@Data9@NoArgsConstructor10@AllArgsConstructor11@Builder12public class ApiResponse<T> {13 14    private boolean success;15    private String message;16    private T data;17    private long timestamp;18 19    public static <T> ApiResponse<T> success(T data) {20        return ApiResponse.<T>builder()21                .success(true)22                .message("Operation successful")23                .data(data)24                .timestamp(System.currentTimeMillis())25                .build();26    }27 28    public static <T> ApiResponse<T> success(String message, T data) {29        return ApiResponse.<T>builder()30                .success(true)31                .message(message)32                .data(data)33                .timestamp(System.currentTimeMillis())34                .build();35    }36 37    public static <T> ApiResponse<T> error(String message) {38        return ApiResponse.<T>builder()39                .success(false)40                .message(message)41                .data(null)42                .timestamp(System.currentTimeMillis())43                .build();44    }45}46