package com.yaoyuan.jiscuss.response; /** * Unified API response wrapper. * * @param payload type */ public record ApiResponse(int code, String msg, T data) { public static ApiResponse ok(T data) { return new ApiResponse<>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg(), data); } public static ApiResponse fail(ResponseCode responseCode) { return new ApiResponse<>(responseCode.getCode(), responseCode.getMsg(), null); } public static ApiResponse error(String message) { return new ApiResponse<>(ResponseCode.SERVICE_ERROR.getCode(), message, null); } }