/**
* Ajax请求的返回内容:增删改
* success:成功与否
* message:失败原因
*/
@Data
public class AjaxResult {
private boolean success = true;
private String message = “操作成功!”;
private Object resultObj;//增加一个对象属性,提高泛用性
private Serializable sessionId;
public boolean isSuccess() {
return success;
}
//链式编程,可以继续. 设置完成后自己对象返回
public AjaxResult setSuccess(boolean success) {
this.success = success;
return this;
}
public AjaxResult setResultObj(Object resultObj){
this.resultObj = resultObj;
return this;
}
public String getMessage() {
return message;
}
public AjaxResult setMessage(String message) {
this.message = message;
return this;
}
//默认成功
public AjaxResult() {
}
//失败调用
public AjaxResult(String message) {
this.success = false;
this.message = message;
}
//使用静态方法创建对象,调用此方法返回的是同一个对象,会占用内存
public static AjaxResult me(){
return new AjaxResult();
}
}