src/ZKEACMS/Widget/WidgetBasePartService.cs

(开头部分) 5KB

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

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

using Easy;
using Easy.Cache;
using Easy.Extend;
using Easy.RepositoryPattern;
using Easy.Serializer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using ZKEACMS.Event;
using ZKEACMS.Page;

namespace ZKEACMS.Widget
{

    public class WidgetBasePartService : ServiceBase<WidgetBasePart, CMSDbContext>, IWidgetBasePartService
    {
        protected const string EncryptWidgetTemplate = "EncryptWidgetTemplate";
        private readonly IWidgetActivator _widgetActivator;

        private readonly ICacheManager<IEnumerable<WidgetBase>> _pageWidgetCacheManage;
        public WidgetBasePartService(IApplicationContext applicationContext,
            IWidgetActivator widgetActivator,
            ICacheManager<IEnumerable<WidgetBase>> pageWidgetCacheManage,
            CMSDbContext dbContext, IEventManager eventManager)
            : base(applicationContext, dbContext)
        {
            _widgetActivator = widgetActivator;
            _pageWidgetCacheManage = pageWidgetCacheManage;
            EventManager = eventManager;
        }
        public IEventManager EventManager { get; private set; }
        public override DbSet<WidgetBasePart> CurrentDbSet => DbContext.WidgetBasePart;

        public override IQueryable<WidgetBasePart> Get()
        {
            return CurrentDbSet.AsNoTracking();
        }

        public IEnumerable<WidgetBase> GetByLayoutId(string layoutId)
        {
            return Get(m => m.LayoutId == layoutId);
        }
        public IEnumerable<WidgetBase> GetByPageId(string pageId)
        {
            return Get(m => m.PageId == pageId);
        }

        public IEnumerable<WidgetBase> GetAllByPage(PageEntity page)
        {
            List<WidgetBase> getPageWidgets(PageEntity p)
            {
                var result = GetByLayoutId(p.LayoutId);
                List<WidgetBase> widgets = result.ToList();
                widgets.AddRange(GetByPageId(p.ID));
后面还有 91 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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