Exemple #1
0
        public async Task <Message> IndexPage([FromBody] Dictionary <string, object> dictionary)
        {
            if (!dictionary.ContainsKey("searchString") || !dictionary.ContainsKey("pageIndex") || !dictionary.ContainsKey("pageSize"))
            {
                return(Message.Fail().Add("content", "参数错误"));
            }
            string searchString = (string)dictionary["searchString"];
            Int64  pageIndex    = (Int64)dictionary["pageIndex"];
            Int64  pageSize     = (Int64)dictionary["pageSize"];

            var items = await _rulesRepository.Page(searchString, Convert.ToInt32(pageIndex), Convert.ToInt32(pageSize));

            bool prePage  = false;
            bool nextPage = false;

            if (items.HasPreViousPage)
            {
                prePage = true;
            }

            if (items.HasNextPage)
            {
                nextPage = true;
            }

            return(Message.Ok().Add("pageData", items).Add("pageSize", pageSize).Add("pageCount", items.Count).Add("pageIndex", pageIndex).Add("totalCount", items.TotalCount).Add("totalPages", items.TotalPages).Add("prePage", prePage).Add("nextPage", nextPage));
        }