package com.ruoyi.common.core.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 响应信息主体
 *
 * @author Lion Li
 */
@Data
@NoArgsConstructor
@ApiModel("请求响应对象")
public class P implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("消息状态码")
    private String code;

    @ApiModelProperty("消息内容")
    private String message;


    public static P ok() {
        return restResult("", "");
    }

    public static P fail(String code, String message) {
        return restResult(code, message);
    }

    private static P restResult(String code, String msg) {
        P r = new P();
        r.setCode(code);
        r.setMessage(msg);
        return r;
    }

}
