主要用于 AJAX请求,返回页面的对象工具类
package com.utils;
/**
* 接受 一般json数据
* @author majunde
*
*/
public class ResultMessage {
// 响应业务状态
private Integer status;
// 响应消息
private String message;
// 响应中的数据
private Object data;
/**
*
* @param status
* @param message
* @param data
* @return
*/
public static ResultMessage build(Integer status, String message, Object data) {
return new ResultMessage(status, message, data);
}
/**
* 正常状态
* @param data
* @return
*/
public static ResultMessage ok(Object data) {
return new ResultMessage(data);
}
/**
* 正常状态
* @return
*/
public static ResultMessage ok() {
return new ResultMessage(null);
}
public ResultMessage() {
}
public static ResultMessage build(Integer status, String message) {
return new ResultMessage(status, message, null);
}
public ResultMessage(Integer status, String message, Object data) {
this.status = status;
this.message = message;
this.data = data;
}
public ResultMessage(Object data) {
this.status = 200;
this.message = "OK";
this.data = data;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
网友评论