com.gitee.fufu669.response.AlphaSimpleResponse Maven / Gradle / Ivy
package com.gitee.fufu669.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/** @author wangfupeng */
@ApiModel("单值返回")
public class AlphaSimpleResponse implements Serializable {
private static final long serialVersionUID = 1L;
protected static final String SUCCESS_STATUS = "000";
protected static final String SUCCESS_MESSAGE = "success";
private T data;
@ApiModelProperty(value = "返回消息,成功为success", example = "success")
private String msg;
@ApiModelProperty(value = "返回状态,成功为000", example = "000")
private String code;
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public static AlphaSimpleResponse success() { return success((T) ""); }
public static AlphaSimpleResponse success(T data) {
return success(data, SUCCESS_MESSAGE, "");
}
public static AlphaSimpleResponse success(T data, String message, String moreInfo) {
return success(data, message, SUCCESS_STATUS, moreInfo);
}
public static AlphaSimpleResponse success(T data, String message, String responseStatus, String moreInfo) {
AlphaSimpleResponse response = new AlphaSimpleResponse();
response.setData(data);
response.setCode(responseStatus);
response.setMsg(message);
return response;
}
public static AlphaSimpleResponse error(String responseStatus, String message, String moreInfo) {
AlphaSimpleResponse response = new AlphaSimpleResponse();
response.setCode(responseStatus);
response.setMsg(message);
return response;
}
public static AlphaSimpleResponse error(String responseStatus, String message) {
return error(responseStatus, message, null);
}
public static AlphaSimpleResponse error(String responseStatus) {
return error(responseStatus, null, null);
}
}