Ejemplo n.º 1
0
        public virtual async Task Init()
        {
            if (_cacheService.Exists(CacheKey.WEBCMSSITE))
            {
                Site = _cacheService.GetCache <CmsSite>(CacheKey.WEBCMSSITE);
            }
            else
            {
                Site = _siteService.GetModelAsync(m => m.Guid == "de0de0fc-ab48-4102-bd69-669260c2271b").Result.data;
                //加入到缓存
                _cacheService.SetCache(CacheKey.WEBCMSSITE, Site, DateTimeOffset.Now.AddDays(30));
            }
            if (_cacheService.Exists($"de0de0fc-ab48-4102-bd69-669260c2271b-columnTree"))
            {
                ColumnTrees = _cacheService.GetCache <List <ColumnTree> >($"de0de0fc-ab48-4102-bd69-669260c2271b-columnTree");
            }
            else
            {
                var columnTree = await _columnService.TreeAsync(1, "de0de0fc-ab48-4102-bd69-669260c2271b");

                ColumnTrees = columnTree.data;
                _cacheService.SetCache($"{HttpContext.Request.Host}columnTree", ColumnTrees);
            }
            if (_cacheService.Exists(CacheKey.WEBCMSADV))
            {
                Adv = _cacheService.GetCache <List <CmsAdvList> >(CacheKey.WEBCMSADV);
            }
            else
            {
                Adv = (await _advService.GetListAsync(m => true, m => m.Sort, DbOrderEnum.Asc)).data;
                //加入到缓存
                _cacheService.SetCache(CacheKey.WEBCMSADV, Adv, DateTimeOffset.Now.AddDays(30));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAdvListPages([FromQuery] PageParm parm)
        {
            var res = await _listService.GetListAsync(m => m.ClassGuid == parm.key, m => m.Sort, DbOrderEnum.Desc);

            return(Ok(new { code = 0, msg = "success", count = 1, res.data }));
        }
Ejemplo n.º 3
0
        public JsonResult GetIndex()
        {
            var Site   = new CmsSite();
            var Column = new List <CmsColumn>();

            //获得站点信息
            if (_cacheService.Exists(CacheKey.WEBCMSSITE))
            {
                Site = _cacheService.GetCache <CmsSite>(CacheKey.WEBCMSSITE);
            }
            else
            {
                Site = _siteService.GetModelAsync(m => m.Guid == "78756a6c-50c8-47a5-b898-5d6d24a20327").Result.data;
                //加入到缓存
                _cacheService.SetCache(CacheKey.WEBCMSSITE, Site, DateTimeOffset.Now.AddDays(30));
            }
            //获得栏目信息
            if (_cacheService.Exists(CacheKey.WEBCMSCOLUMN))
            {
                Column = _cacheService.GetCache <List <CmsColumn> >(CacheKey.WEBCMSCOLUMN);
            }
            else
            {
                Column = _columnService.GetListAsync(m => true, m => m.Sort, DbOrderEnum.Asc).Result.data;
                //加入到缓存
                _cacheService.SetCache(CacheKey.WEBCMSCOLUMN, Column, DateTimeOffset.Now.AddDays(30));
            }

            //查询焦点图
            var banner = _listService.GetListAsync(m => m.ClassGuid == "e8b4325d-bdd8-448f-83be-034d66642b14" && m.Status, m => m.Sort, DbOrderEnum.Desc).Result.data.Select(m => new {
                linkUrl = m.LinkUrl,
                title   = m.Title,
                imgUrl  = m.ImgUrl
            }).ToList();

            //查询案例,按权重和日期排序
            var caseColumn = Column.Where(m => m.ParentId == 1015).ToList();
            var Case       = _articleService.WebGetList(new PageParm()
            {
                limit = 10, types = 1, where = "istop=1"
            }, caseColumn.Select(m => m.Id).ToList()).Items.Select(m => new {
                id     = m.Id,
                title  = m.Title,
                imgUrl = m.ImgUrl,
                tag    = m.Tag
            }).ToList();

            //查询新闻,按权重和日期排序
            var articleColumn = Column.Where(m => m.ParentId == 1016).ToList();
            var Article       = _articleService.WebGetList(new PageParm()
            {
                limit = 4, types = 1
            }, articleColumn.Select(m => m.Id).ToList()).Items.Select(m => new {
                id      = m.Id,
                title   = m.Title,
                imgUrl  = m.ImgUrl,
                addDate = m.AddDate
            }).ToList();

            return(Json(new { banner, cases = Case, article = Article,
                              site = new { title = Site.SeoTitle, key = Site.SeoKey, desc = Site.SeoDescribe }
                              , newcolumn = articleColumn.Select(m => new { m.Id, m.Title }).ToList()
                              , casecolumn = caseColumn.Select(m => new { m.Id, m.Title }).ToList() }));
        }