From 07dda8f5d6315e5c373ac04ee32a97ea61f941d1 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期一, 12 九月 2022 17:12:46 +0800 Subject: [PATCH] add isError and isSuccess method --- src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java b/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java index 5c551bd..cba99ba 100644 --- a/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java +++ b/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java @@ -1,6 +1,7 @@ package com.ruoyi.framework.web.domain; import java.util.HashMap; +import java.util.Objects; import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.utils.StringUtils; @@ -145,4 +146,38 @@ { return new AjaxResult(code, msg, null); } + + /** + * 鏄惁涓烘垚鍔熸秷鎭� + * + * @return 缁撴灉 + */ + public boolean isSuccess() + { + return !isError(); + } + + /** + * 鏄惁涓洪敊璇秷鎭� + * + * @return 缁撴灉 + */ + public boolean isError() + { + return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); + } + + /** + * 鏂逛究閾惧紡璋冪敤 + * + * @param key 閿� + * @param value 鍊� + * @return 鏁版嵁瀵硅薄 + */ + @Override + public AjaxResult put(String key, Object value) + { + super.put(key, value); + return this; + } } -- Gitblit v1.9.3