All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.erupt.core.view.R Maven / Gradle / Ivy

There is a newer version: 1.12.17
Show newest version
package xyz.erupt.core.view;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author YuePeng
 */
@Getter
@Setter
public class R implements Serializable {

    //消息
    private String msg;

    //数据
    private T data;

    //是否成功
    private boolean success;

    //状态
    private EruptApiModel.Status status;

    //提示方式
    private EruptApiModel.PromptWay promptWay = EruptApiModel.PromptWay.MESSAGE;

    public static  R ok(T data) {
        return new R() {{
            this.setSuccess(true);
            this.setData(data);
            this.setStatus(EruptApiModel.Status.SUCCESS);
        }};
    }

    public static R error(String msg) {
        return new R() {{
            this.setSuccess(false);
            this.setMsg(msg);
            this.setStatus(EruptApiModel.Status.ERROR);
        }};
    }

    public enum Status {
        SUCCESS, ERROR, INFO, WARNING
    }

    public enum PromptWay {
        DIALOG, MESSAGE, NOTIFY, NONE
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy