//get set方法未加,正常项目中需添加
public class Result<T> {
private T result;
private boolean success = true;
private int errorCode;
private String errorMessage;
private Throwable reason;
public Result(T result) {
if(result == null)
{
this.success = false;
this.errorCode = -1;
}
this.result = result;
}
public Result(int code,String errorMessage,T result,Throwable reason) {
if(result == null)
{
this.errorCode = -1;
}
else
{
this.errorCode = code;
}
this.success = false;
this.result = result;
this.errorMessage = errorMessage;
this.reason = reason;
}
public Result(int errorCode, String errorMessage) {
this(errorCode,errorMessage,null);
}
public Result(int errorCode, String errorMessage, Throwable reason) {
this.errorCode = errorCode;
this.errorMessage = errorMessage;
this.reason = reason;
this.success=false;
}
}
接口返回统一格式
最新推荐文章于 2024-03-14 20:21:57 发布