コード例 #1
0
        public HttpResponseMessage GetThematicArticleList(ThematicArticleListArg arg)
        {
            BaseJson4Page <ZTArticleViewModel> resultMsg = new BaseJson4Page <ZTArticleViewModel> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(ThematicArticleController), arg.TryToJson(), "获取专题文章列表-GetThematicArticleList", () =>
            {
                if (!string.IsNullOrEmpty(arg.t))
                {
                    if (arg.t.CheckTimeStamp())
                    {
                        string sql = $"SELECT [Id],[Title],[ShortDetail],[Addtime] FROM [dbo].[ZT_Article] WHERE Cid = {arg.CId}";

                        DataTable data = commonBll.FindPageDataTable(sql, "Addtime", false, arg.PageSize, arg.PageIndex, out int total, DatabaseLinksEnum.CB55128);
                        if (data.IsExistRows())
                        {
                            List <ZTArticleViewModel> res = data.DataTableToList <ZTArticleViewModel>();

                            PageData <ZTArticleViewModel> pageData = new PageData <ZTArticleViewModel>
                            {
                                TotalRow  = total,
                                TotalPage = (int)Math.Floor(total * 1.0 / arg.PageSize) + 1,
                                PageIndex = arg.PageIndex,
                                Rows      = res
                            };

                            resultMsg = new BaseJson4Page <ZTArticleViewModel>
                            {
                                Status  = (int)JsonObjectStatus.Success,
                                Data    = pageData,
                                Message = JsonObjectStatus.Success.GetEnumText(),
                                BackUrl = null
                            };
                        }
                        else
                        {
                            resultMsg = new BaseJson4Page <ZTArticleViewModel>
                            {
                                Status  = (int)JsonObjectStatus.Success,
                                Data    = null,
                                Message = JsonObjectStatus.Success.GetEnumText(),
                                BackUrl = null
                            };
                        }
                    }