RetResult增加Map<String, String> attach成员变量

This commit is contained in:
Redkale
2017-10-17 09:42:32 +08:00
parent e0041235fe
commit 99589387d8

View File

@@ -5,6 +5,7 @@
*/
package org.redkale.service;
import java.util.*;
import org.redkale.convert.json.*;
/**
@@ -28,6 +29,8 @@ public class RetResult<T> {
protected T result;
protected Map<String, String> attach;
public RetResult() {
}
@@ -99,6 +102,32 @@ public class RetResult<T> {
return this;
}
/**
* 同 setAttach
*
* @param attach attach
*
* @return RetResult
*/
public RetResult<T> attach(Map<String, String> attach) {
this.attach = attach;
return this;
}
/**
* attach添加元素
*
* @param key String
* @param value String
*
* @return RetResult
*/
public RetResult<T> 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<T> {
this.result = result;
}
/**
* 结果附件
*
* @return 结果附件
*/
public Map<String, String> getAttach() {
return attach;
}
/**
* 设置结果附件
*
* @param attach Map
*/
public void setAttach(Map<String, String> attach) {
this.attach = attach;
}
@Override
public String toString() {
return JsonConvert.root().convertTo(this);