package com.xly.erp.common.response; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor public class ApiResponse { private int code; private String message; private T data; private long timestamp; public static ApiResponse ok(T data) { return new ApiResponse<>(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMessage(), data, System.currentTimeMillis()); } public static ApiResponse ok(String message, T data) { return new ApiResponse<>(ErrorCode.SUCCESS.getCode(), message, data, System.currentTimeMillis()); } public static ApiResponse fail(ErrorCode ec) { return new ApiResponse<>(ec.getCode(), ec.getMessage(), null, System.currentTimeMillis()); } public static ApiResponse fail(ErrorCode ec, String detail) { return new ApiResponse<>(ec.getCode(), detail, null, System.currentTimeMillis()); } public static ApiResponse fail(int code, String message) { return new ApiResponse<>(code, message, null, System.currentTimeMillis()); } }