package com.xly.erp.common.response; import lombok.Getter; /** * 统一响应包装。 * docs/04 § 1.3。 */ @Getter public class Result { private final int code; private final String message; private final T data; private final long timestamp; private Result(int code, String message, T data) { this.code = code; this.message = message; this.data = data; this.timestamp = System.currentTimeMillis(); } public static Result ok(T data) { return new Result<>(ErrorCode.OK, "操作成功", data); } public static Result ok() { return new Result<>(ErrorCode.OK, "操作成功", null); } public static Result fail(int code, String message) { return new Result<>(code, message, null); } }