91 lines
1.9 KiB
Java
91 lines
1.9 KiB
Java
package net.tccn.bbs.base;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* Created by liangxianyou
|
|
*/
|
|
public class JBean<T> /*extends RetResult*/ {
|
|
private int retcode;
|
|
private String retinfo = "";
|
|
private T result;
|
|
private Map<String, Object> attach;
|
|
|
|
public JBean(int retcode) {
|
|
this.retcode = retcode;
|
|
}
|
|
|
|
public JBean(int retcode, String retinfo) {
|
|
this.retcode = retcode;
|
|
this.retinfo = retinfo;
|
|
}
|
|
|
|
public static JBean by(int retcode, String retinfo){
|
|
JBean jBean = new JBean(retcode, retinfo);
|
|
return jBean;
|
|
}
|
|
|
|
public static JBean by(int retcode, String retinfo, Object t){
|
|
JBean jBean = new JBean(retcode, retinfo);
|
|
jBean.setResult(t);
|
|
return jBean;
|
|
}
|
|
|
|
public JBean(T result) {
|
|
this.result = result;
|
|
}
|
|
|
|
public int getRetcode() {
|
|
return retcode;
|
|
}
|
|
|
|
public void setRetcode(int retcode) {
|
|
this.retcode = retcode;
|
|
}
|
|
|
|
public String getRetinfo() {
|
|
return retinfo;
|
|
}
|
|
|
|
public void setRetinfo(String retinfo) {
|
|
this.retinfo = retinfo;
|
|
}
|
|
|
|
public T getResult() {
|
|
return result;
|
|
}
|
|
|
|
public void setResult(T result) {
|
|
this.result = result;
|
|
}
|
|
|
|
public Map<String, Object> getAttach() {
|
|
return attach;
|
|
}
|
|
|
|
public void setAttach(Map<String, Object> attach) {
|
|
this.attach = attach;
|
|
}
|
|
|
|
public JBean attach(String key, Object object){
|
|
if (attach == null)
|
|
attach = new HashMap<>();
|
|
attach.put(key, object);
|
|
return this;
|
|
}
|
|
|
|
private static final JBean ok = new JBean(0);
|
|
public static JBean ok(){
|
|
return ok;
|
|
}
|
|
|
|
public static JBean faild(String retinfo){
|
|
return new JBean(-1, retinfo);
|
|
}
|
|
|
|
public static JBean by(Object object) {
|
|
return new JBean(object);
|
|
}
|
|
}
|