public EmsModel.JsonModel GetJsonModel(EmsModel.Role role) { //当前页 int pageIndex = 1; //页容量 int pageSize = 16; List <EmsModel.Role> modList = GetList(role); //定义分页数据实体 PagedDataModel <EmsModel.Role> pagedDataModel = null; //定义JSON标准格式实体中 JsonModel jsonModel = null; if (modList.Count > 0) { var list = modList; //总条数 int rowCount = modList.Count; //总页数 int pageCount = (int)Math.Ceiling(rowCount * 1.0 / pageSize); //将数据封装到PagedDataModel分页数据实体中 pagedDataModel = new PagedDataModel <EmsModel.Role>() { PageCount = pageCount, PagedData = list, PageIndex = pageIndex, PageSize = pageSize, RowCount = rowCount }; //将分页数据实体封装到JSON标准实体中 jsonModel = new JsonModel() { Data = pagedDataModel, Msg = "成功", Status = "ok", BackUrl = "" }; return(jsonModel); } else { jsonModel = new JsonModel() { Status = "no", Msg = "失败" }; return(jsonModel); } }
/// <summary> /// 获取泛型数据列表 /// </summary> public List <EmsModel.Role> GetList(EmsModel.Role role) { return(dal.GetList(role)); }