package com.yihu.ehr.util.rest; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * 信封对象,封装REST接口的返回值内容。包括: * - 页码 * - 页大小 * - 错误消息 * - 错误代码 * - 对象模型 * * 信封对象的返回场景: * - API使用者确实无法访问返回头,即一些语言库无法处理HTTP的响应消息,这时候需要以这种形式提供返回值。 * - API需要支持交叉域请求(通过JSONP)。 * * @author llh */ public class Envelop implements Serializable{ private static final long serialVersionUID = 2076324875575488461L; private boolean successFlg; private int pageSize = 15; private int currPage = 1; private int totalPage = 0; private int totalCount; private List detailModelList = new ArrayList<>(); private J obj = (J) new HashMap<>(0); private String errorMsg; private int errorCode; public boolean isSuccessFlg() { return successFlg; } public void setSuccessFlg(boolean successFlg) { this.successFlg = successFlg; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getCurrPage() { return currPage; } public void setCurrPage(int currPage) { this.currPage = currPage; } public int getTotalPage() { if(pageSize == 0){ pageSize = 15; } if (totalCount % pageSize > 0) { totalPage = totalCount / pageSize + 1; } else { totalPage = totalCount / pageSize; } return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; } public int getTotalCount() { return totalCount; } public void setTotalCount(int totalCount) { this.totalCount = totalCount; } public List getDetailModelList() { return detailModelList; } public void setDetailModelList(List detailModelList) { this.detailModelList = detailModelList; } public J getObj() { return obj; } public void setObj(J obj) { this.obj = obj; } public String getErrorMsg() { return errorMsg; } public void setErrorMsg(String errorMsg) { this.errorMsg = errorMsg; } public int getErrorCode() { return errorCode; } public void setErrorCode(int errorCode) { this.errorCode = errorCode; } }