源码:
public class ResponeBean {
private Integer code; // 响应状态码
private String message; // 提示信息
private Object data; // 返回数据
// 根据相应的方法封装相应的对象进行返回
public static ResponeBean ok(String message) {
return new ResponeBean(200, message);
}
public static ResponeBean ok(String message, Object data) {
return new ResponeBean(200, message, data);
}
public static ResponeBean error(String message) {
return new ResponeBean(500, message);
}
public static ResponeBean error(String message, Object data) {
return new ResponeBean(500, message, data);
}
//私有的构造器 只能通过本类的方法创建对象
private ResponeBean(Integer code, String message, Object data) {
this.code = code;
this.message = message;
this.data = data;
}
private ResponeBean(Integer code, String message) {
this.code = code;
this.message = message;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}