无关风月
2025-02-28 dd663d0ac783755d889e270eee57ee58630c88c8
xinquan-common/xinquan-common-core/src/main/java/com/xinquan/common/core/domain/R.java
@@ -1,7 +1,8 @@
package com.xinquan.common.core.domain;
import java.io.Serializable;
import com.xinquan.common.core.constant.Constants;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 响应信息主体
@@ -14,14 +15,23 @@
    /** 成功 */
    public static final int SUCCESS = Constants.SUCCESS;
    /**
     * token失效
     */
    public static final int TOKEN_ERROR = Constants.TOKEN_ERROR;
    public static final int GIVE_ERROR = Constants.GIVE_ERROR;
    public static final int VALUE_ERROR = Constants.VALUE_ERROR;
    /** 失败 */
    public static final int FAIL = Constants.FAIL;
    @ApiModelProperty(value = "业务状态码,200-成功,其它-失败")
    private int code;
    @ApiModelProperty(value = "响应消息", example = "操作成功")
    private String msg;
    @ApiModelProperty(value = "响应数据")
    private T data;
    public static <T> R<T> ok()
@@ -29,6 +39,18 @@
        return restResult(null, SUCCESS, null);
    }
    public static <T> R<T> tokenError(String msg)
    {
        return restResult(null, TOKEN_ERROR, msg);
    }
    public static <T> R<T> giveError(String msg)
    {
        return restResult(null, GIVE_ERROR, msg);
    }
    public static <T> R<T> energyValueError(String msg)
    {
        return restResult(null, VALUE_ERROR, msg);
    }
    public static <T> R<T> ok(T data)
    {
        return restResult(data, SUCCESS, null);