增加对AjaxResult消息结果类型的判断
parent
08f775da4b
commit
960dee7756
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,20 +82,6 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 方便链式调用
|
|
||||||
*
|
|
||||||
* @param key 键
|
|
||||||
* @param value 值
|
|
||||||
* @return 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AjaxResult put(String key, Object value)
|
|
||||||
{
|
|
||||||
super.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*
|
*
|
||||||
|
@ -193,4 +180,38 @@ public class AjaxResult extends HashMap<String, Object>
|
||||||
{
|
{
|
||||||
return new AjaxResult(Type.ERROR, msg, data);
|
return new AjaxResult(Type.ERROR, msg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为成功消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isSuccess()
|
||||||
|
{
|
||||||
|
return !isError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为错误消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isError()
|
||||||
|
{
|
||||||
|
return Objects.equals(Type.SUCCESS, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方便链式调用
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return 数据对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult put(String key, Object value)
|
||||||
|
{
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue