public class BackResult{
//总记录数
private int total;
//当前记录集合
private Object data;
//是否成功
private boolean successful;
//结果消息
private String resultMsg;
//错误类型
private String type;
//返回成功信息。
public static BackResult successResult(Object data){
return new BackResult(1,data,true,"","");
}
//返回成功信息
public static BackResult successResult(Object data,int total) {
return new BackResult(total,data,true,"","");
}
//返回错误信息
public static BackResult failedResult(String message){
return new BackResult(0,"",false,message,"error");
}
//返回失败信息和类型
public static BackResult failedResult(String message,String type){
return new BackResult(0,"",false,message,type);
}
public BackResult(){
type = "error";
}
public BackResult(int total,Object data,boolean successful,String resultMsg,String type){
this.total = total;
this.data = data;
this.successful = successful;
this.resultMsg = resultMsg;
this.type = type;
}
//以下省略getter/setter
}
请求返回对象
最新推荐文章于 2021-08-05 12:38:25 发布