src/ZKEACMS.Article/Service/ArticleListWidgetService.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Easy;
using Easy.RepositoryPattern;
using Microsoft.AspNetCore.Http;
using ZKEACMS.Article.Models;
using ZKEACMS.Article.ViewModel;
using ZKEACMS.Widget;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using System;
using Microsoft.AspNetCore.Mvc;
using System.Linq.Expressions;
using ZKEACMS.Page;
using Easy.Extend;

namespace ZKEACMS.Article.Service
{
    public class ArticleListWidgetService : WidgetService<ArticleListWidget>
    {
        private readonly IArticleTypeService _articleTypeService;
        private readonly IArticleService _articleService;
        private readonly IPageService _pageService;
        public ArticleListWidgetService(IWidgetBasePartService widgetService, IArticleTypeService articleTypeService,
            IArticleService articleService, IApplicationContext applicationContext, IPageService pageService, CMSDbContext dbContext)
            : base(widgetService, applicationContext, dbContext)
        {
            _articleTypeService = articleTypeService;
            _articleService = articleService;
            _pageService = pageService;
        }

        private string GetDetailPageUrl()
        {
            var baseDetail = WidgetBasePartService.Get(m => m.ServiceTypeName == "ZKEACMS.Article.Service.ArticleDetailWidgetService").FirstOrDefault();
            if (baseDetail != null)
            {
                var page = _pageService.Get(baseDetail.PageId);
                if (page != null)
                {
                    return page.Url;
                }
            }
            return "~/article-detail";
        }

        public override ServiceResult<ArticleListWidget> Add(ArticleListWidget item)
        {
            if (item.DetailPageUrl.IsNullOrEmpty())
            {
                item.DetailPageUrl = GetDetailPageUrl();
            }
            return base.Add(item);
        }

        public override ArticleListWidget Get(params object[] primaryKeys)
        {
后面还有 63 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。