增加对AjaxResult消息结果类型的判断

This commit is contained in:
RuoYi 2022-08-02 12:08:18 +08:00
parent 08f775da4b
commit 960dee7756

View File

@ -1,6 +1,7 @@
package com.ruoyi.common.core.domain;
import java.util.HashMap;
import java.util.Objects;
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 结果
*/
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;
}
}