package yhs.jzl.information.revicemanggerrun.activity;
import java.util.HashMap;
import java.util.Map;
/**
* 操作消息提醒
*
*/
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/**
* 初始化一个新创建的 Message 对象
*/
public AjaxResult() {
}
/**
* 返回错误消息
*
* @return 错误消息
*/
public static AjaxResult error() {
return error(1, "操作失败");
}
/**
* 返回错误消息
*
* @param msg 内容
* @return 错误消息
*/
public static AjaxResult error(String msg) {
return error(500, msg);
}
/**
* 返回错误消息
*
* @param code 错误码
* @param msg 内容
* @return 错误消息
*/
public static AjaxResult error(int code, String msg) {
AjaxResult json = new AjaxResult();
json.put("code", code);
json.put("msg", msg);
return json;
}
/**
* 返回错误消息
*
* @param code 错误码
* @param msg 错误消息
* @param data 附加内容
* @return 错误消息
*/
public static AjaxResult error(int code, String msg, Object data) {
AjaxResult json = new AjaxResult();
json.put("code", code);
json.put("msg", msg);
json.put("data", data);
return json;
}
/**
* 返回成功消息
*
* @param msg 内容
* @return 成功消息
*/
public static AjaxResult success(String msg) {
AjaxResult json = new AjaxResult();
json.put("msg", msg);
json.put("code", 0);
return json;
}
/**
* 返回成功 带对象
*
* @param data 对象内容
* @return 成功消息
*/
public static AjaxResult success(Object data) {
AjaxResult json = new AjaxResult();
json.put("msg", "");
json.put("code", 0);
json.put("data", data);
return json;
}
/**
* 返回成功 带map
*
* @param map 对象内容
* @return 成功消息
*/
public static AjaxResult success(Map<String, Object> map) {
AjaxResult json = new AjaxResult();
json.put("msg", "");
json.put("code", 0);
json.putAll(map);
return json;
}
/**
* 返回成功 带对象
*
* @param data 对象内容
* @return 成功消息
*/
public static AjaxResult success(Object[] data) {
AjaxResult json = new AjaxResult();
json.put("msg", "");
json.put("code", 0);
json.put("data", data);
return json;
}
/**
* 返回成功消息
*
* @return 成功消息
*/
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
/**
* 返回成功消息
*
* @param key 键值
* @param value 内容
* @return 成功消息
*/
@Override
public AjaxResult put(String key, Object value) {
super.put(key, value);
return this;
}
}
public class RespBean {
private Integer status;
private String msg;
private Object obj;
public static RespBean build() {
return new RespBean();
}
public static RespBean ok(String msg) {
return new RespBean(200, msg, null);
}
public static RespBean ok(String msg, Object obj) {
return new RespBean(200, msg, obj);
}
public static RespBean error(String msg) {
return new RespBean(500, msg, null);
}
public static RespBean error(String msg, Object obj) {
return new RespBean(500, msg, obj);
}
private RespBean() {
}
private RespBean(Integer status, String msg, Object obj) {
this.status = status;
this.msg = msg;
this.obj = obj;
}
public Integer getStatus() {
return status;
}
public RespBean setStatus(Integer status) {
this.status = status;
return this;
}
public String getMsg() {
return msg;
}
public RespBean setMsg(String msg) {
this.msg = msg;
return this;
}
public Object getObj() {
return obj;
}
public RespBean setObj(Object obj) {
this.obj = obj;
return this;
}
}