Example #1
0
        public async Task OnGetAsync(long id)
        {
            //取得栏目及子栏目信息
            var columns = await _columnService.GetListFromCacheAsync();
            List<long> columnIds = new List<long>();
            void GetColumnId(long cid)
            {
                var column = columns.SingleOrDefault(x=>x.Id == cid);
                if (column != null)
                {
                    columnIds.Add(column.Id);
                    if (column.Subs != null || column.Subs.Any())
                    {
                        foreach (var item in column.Subs)
                        {
                            GetColumnId(item.Id);
                        }
                    }
                }
            }
            GetColumnId(id);

            //取得文章列表
            var data = await _articleService.GetListAsync(1, 20,new ArticleSearch { IsPublished = true, IsDeleted = false, ColumnIds = columnIds.ToArray() }, "PublishedTime desc, CreateTime desc");
        }