com.zznote.basecommon.common.util.Rm Maven / Gradle / Ivy
The newest version!
package com.zznote.basecommon.common.util;
import java.util.HashMap;
import java.util.Map;
public class Rm extends HashMap {
private static final long serialVersionUID = 1L;
public Rm() {
put("code", 200);
put("msg", "success");
}
public static Rm error() {
return error(9999, "未知异常,请联系管理员");
}
public static Rm error(String msg) {
return error(9999, msg);
}
public static Rm error(Integer code, String msg) {
Rm rm = new Rm();
rm.put("code", code);
rm.put("msg", msg);
return rm;
}
public static Rm success(String msg) {
Rm rm = new Rm();
rm.put("msg", msg);
return rm;
}
public static Rm success(Map map) {
Rm rm = new Rm();
rm.putAll(map);
return rm;
}
public static Rm success() {
return new Rm();
}
/**
* 未授权
*
* @param message 信息
* @return
*/
public static Rm unAuth(String message) {
return Rm.error(401, message);
}
@Override
public Rm put(String key, Object value) {
super.put(key, value);
return this;
}
/**
* 返回格式化
*
* @param row 改变行数
* @return
*/
public static Rm toAjax(int row) {
return row > 0 ? success() : error();
}
/**
* 返回格式化
*
* @param status 修改状态
* @return
*/
public static Rm toAjax(boolean status) {
return status ? success() : error();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy