返回对象result封装_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 返回对象result封装

返回对象result封装

 2014/8/22 12:31:36  慕容亦欢  程序员俱乐部  我要评论(0)
  • 摘要:importtf56.sofa.serializer.JsonGenerateUtil;/***返回对象Result封装*@athorchangmeng.liu*@date2014-7-25*@version1.0*@update*/publicclassResult{finalStringSUCCESS="success";finalStringERROR="error";privateStringcount="";/**响应数据*/privateObjectdata
  • 标签:
class="java" name="code">
import tf56.sofa.serializer.JsonGenerateUtil;

/**
 * 返回对象Result封装
 * @athor changmeng.liu
 * @date 2014-7-25
 * @version 1.0
 * @update 
 */
public class Result {
	final String SUCCESS="success";
	final String ERROR="error";
	private String count="";
	/** 响应数据 */
    private Object data;
    /** 响应分页 */
	/** 响应状态 */
    private Boolean status = true;
    /** 响应消息 */
    private String message;

    public Result() {}

    public Result(Object data) {
    	this.data = data;
    }

   

    public Result(String message, Boolean status) {
    	this.set(message, status);
    }

    public Result(String message, Boolean status,String count, Object data) {
    	this.set(message, status);
    	this.data = data;
    	this.count=count;
    }

   

    public void set(String message, Boolean status) {
    	this.status = status;
    	this.message = message;
    	this.count="";
    	this.data="";
    }

    public void set(String message, Boolean status,String count, Object data) {
    	this.status = status;
    	this.message = message;
    	this.data = data;
    	this.count=count;
    }

    public Boolean getStatus() {
		return status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
		this.message=this.status?"成功":"失败";
		this.count="";
    	this.data="";
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String getCommonJson(){
		return JsonGenerateUtil.getCommonJson(status==true?SUCCESS:ERROR, message, count==null?"":count, data==null?"":data);
	}

}
  • 相关文章
发表评论
用户名: 匿名