diff --git a/src/org/redkale/service/RetResult.java b/src/org/redkale/service/RetResult.java index 49a4d6d0d..c9c381bd7 100644 --- a/src/org/redkale/service/RetResult.java +++ b/src/org/redkale/service/RetResult.java @@ -5,7 +5,6 @@ */ package org.redkale.service; -import java.io.Serializable; import java.util.*; import org.redkale.convert.json.*; @@ -30,7 +29,7 @@ public class RetResult { protected T result; - protected Map attach; + protected Map attach; public RetResult() { } @@ -110,7 +109,7 @@ public class RetResult { * * @return RetResult */ - public RetResult attach(Map attach) { + public RetResult attach(Map attach) { this.attach = attach; return this; } @@ -119,13 +118,14 @@ public class RetResult { * attach添加元素 * * @param key String - * @param value Serializable + * @param value String * * @return RetResult */ - public RetResult attach(String key, Serializable value) { + public RetResult attach(String key, Object value) { if (this.attach == null) this.attach = new HashMap<>(); - this.attach.put(key, value); + boolean canstr = value != null && (value instanceof CharSequence || value.getClass().isPrimitive()); + this.attach.put(key, value == null ? null : (canstr ? String.valueOf(value) : JsonConvert.root().convertTo(value))); return this; } @@ -183,26 +183,16 @@ public class RetResult { * * @return 结果附件 */ - public Map getAttach() { + public Map getAttach() { return attach; } - public Serializable findAttachValue(String key) { - return attach == null ? null : attach.get(key); - } - - public String findAttachStringValue(String key) { - if (attach == null) return null; - Serializable val = attach.get(key); - return val == null ? null : val.toString(); - } - /** * 设置结果附件 * * @param attach Map */ - public void setAttach(Map attach) { + public void setAttach(Map attach) { this.attach = attach; }