返回封装
import java.io.Serializable;
public class ResponseForm implements Serializable {
private static final long serialVersionUID = 1L;
private Boolean status;
private Object data;
private String msg;
public static ResponseForm successResponse(Object data) {
ResponseForm res = new ResponseForm();
res.setStatus(Boolean.TRUE);
res.setData(data);
res.setMsg("操作成功");
return res;
}
public static ResponseForm errorResponse(Object data) {
ResponseForm res = new ResponseForm();
res.setStatus(Boolean.FALSE);
res.setData(data);
res.setMsg("操作失败");
return res;
}
public static ResponseForm successResponse() {
ResponseForm res = new ResponseForm();
res.setStatus(Boolean.TRUE);
res.setData("");
res.setMsg("操作成功");
return res;
}
public static ResponseForm errorResponse() {
ResponseForm res = new ResponseForm();
res.setStatus(Boolean.FALSE);
res.setData("");
res.setMsg("操作失败");
return res;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public String toString() {
return "ResponseForm{" + "status=" + status + ", data=" + data + ", msg='" + msg + '\'' + '}';
}
}