Standard API Response Wrapper (domain/R.java)

ruoyi-ai · ruoyi-common/ruoyi-common-core/src/main/java/org/ruoyi/common/core/domain/R.java · java · MIT
database, dev-tools, integration, lang:java, tag:response, tag:utility

A generic container for API responses providing consistent status codes and messages. Use this to standardize JSON output across your service endpoints.

// Source: https://github.com/ageerle/ruoyi-ai | License: MIT | Copyright 2026 ruoyi-ai
// Provided via justclaw.it.com; keep this notice with the code.
package org.ruoyi.common.core.domain;

import org.ruoyi.common.core.constant.HttpStatus;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * 响应信息主体
 *
 * @author Lion Li
 */
@Data
@NoArgsConstructor
public class R<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 成功
     */
    public static final int SUCCESS = 200;

    /**
     * 失败
     */
    public static final int FAIL = 500;

    private int code;

    private String msg;

    private T data;

    public static <T> R<T> ok() {
        return restResult(null, SUC

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key