diff --git a/src/org/redkale/service/RetResult.java b/src/org/redkale/service/RetResult.java index d343cf175..62acf2d6f 100644 --- a/src/org/redkale/service/RetResult.java +++ b/src/org/redkale/service/RetResult.java @@ -5,6 +5,7 @@ */ package org.redkale.service; +import java.util.*; import org.redkale.convert.json.*; /** @@ -28,6 +29,8 @@ public class RetResult { protected T result; + protected Map attach; + public RetResult() { } @@ -99,6 +102,32 @@ public class RetResult { return this; } + /** + * 同 setAttach + * + * @param attach attach + * + * @return RetResult + */ + public RetResult attach(Map attach) { + this.attach = attach; + return this; + } + + /** + * attach添加元素 + * + * @param key String + * @param value String + * + * @return RetResult + */ + public RetResult attach(String key, Object value) { + if (this.attach == null) this.attach = new HashMap<>(); + this.attach.put(key, value == null ? null : String.valueOf(value)); + return this; + } + /** * 结果码 0表示成功、 非0表示错误 * @@ -148,6 +177,24 @@ public class RetResult { this.result = result; } + /** + * 结果附件 + * + * @return 结果附件 + */ + public Map getAttach() { + return attach; + } + + /** + * 设置结果附件 + * + * @param attach Map + */ + public void setAttach(Map attach) { + this.attach = attach; + } + @Override public String toString() { return JsonConvert.root().convertTo(this);