src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using Easy;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using ZKEACMS.Article.Models;
using ZKEACMS.Article.ViewModel;
using ZKEACMS.Widget;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using Easy.Extend;
using System.Collections.Concurrent;
using Easy.Cache;
using Easy.RepositoryPattern;
namespace ZKEACMS.Article.Service
{
public class ArticleDetailWidgetService : WidgetService<ArticleDetailWidget>
{
private const string ArticleDetailWidgetRelatedPageUrls = "ArticleDetailWidgetRelatedPageUrls";
private readonly IArticleService _articleService;
private readonly ConcurrentDictionary<string, object> _allRelatedUrlCache;
public ArticleDetailWidgetService(IWidgetBasePartService widgetService,
IArticleService articleService,
IApplicationContext applicationContext,
ICacheManager<ConcurrentDictionary<string, object>> cacheManager,
CMSDbContext dbContext)
: base(widgetService, applicationContext, dbContext)
{
_articleService = articleService;
_allRelatedUrlCache = cacheManager.GetOrAdd(ArticleDetailWidgetRelatedPageUrls, new ConcurrentDictionary<string, object>());
}
private void DismissRelatedPageUrls()
{
_allRelatedUrlCache.TryRemove(ArticleDetailWidgetRelatedPageUrls, out var urls);
}
public override ServiceResult<ArticleDetailWidget> Add(ArticleDetailWidget item)
{
var result = base.Add(item);
DismissRelatedPageUrls();
return result;
}
public override ServiceResult<ArticleDetailWidget> Update(ArticleDetailWidget item)
{
var result = base.Update(item);
DismissRelatedPageUrls();
return result;
}
public override void DeleteWidget(string widgetId)
{
base.DeleteWidget(widgetId);
DismissRelatedPageUrls();
}
public override object Display(WidgetDisplayContext widgetDisplayContext)
{
后面还有 51 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。