public class CommonRetrunType {
//表明对应请求的返回处理结果 “success” 或 “error”
private String status;
//若status=success,则data内返回前端需要的json数据
//若status=error,则data内使用通用的错误码格式
private Object data;
//处理成功的方法
public static CommonRetrunType create(Object result){
return CommonRetrunType.create(result,"success");
}
//处理错误的方法
public static CommonRetrunType create(Object result, String status) {
CommonRetrunType type = new CommonRetrunType();
type.setData(result);
type.setStatus(status);
return type;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}