src/ZKEACMS.Product/Service/ProductCategoryWidgetService.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using ZKEACMS.Product.Models;
using ZKEACMS.Product.ViewModel;
using Easy.Extend;
using ZKEACMS.Widget;
using Microsoft.AspNetCore.Http;
using Easy;
using Microsoft.EntityFrameworkCore;
using System;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Collections.Concurrent;
using Easy.Constant;
namespace ZKEACMS.Product.Service
{
public class ProductCategoryWidgetService : WidgetService<ProductCategoryWidget>
{
private const string ProductCategoryWidgetRelatedPageUrls = "ProductCategoryWidgetRelatedPageUrls";
private readonly ConcurrentDictionary<string, object> _allRelatedUrlCache;
private readonly IProductCategoryService _productCategoryService;
public ProductCategoryWidgetService(IWidgetBasePartService widgetService,
IProductCategoryService productCategoryService,
IApplicationContext applicationContext,
Easy.Cache.ICacheManager<ConcurrentDictionary<string, object>> cacheManager,
CMSDbContext dbContext)
: base(widgetService, applicationContext, dbContext)
{
_productCategoryService = productCategoryService;
_allRelatedUrlCache = cacheManager.GetOrAdd(ProductCategoryWidgetRelatedPageUrls, new ConcurrentDictionary<string, object>());
}
private void DismissRelatedPageUrls()
{
_allRelatedUrlCache.TryRemove(ProductCategoryWidgetRelatedPageUrls, out var urls);
}
public override void AddWidget(WidgetBase widget)
{
base.AddWidget(widget);
DismissRelatedPageUrls();
}
public override void DeleteWidget(string widgetId)
{
base.DeleteWidget(widgetId);
DismissRelatedPageUrls();
}
public override object Display(WidgetDisplayContext widgetDisplayContext)
{
ProductCategoryWidget currentWidget = widgetDisplayContext.Widget as ProductCategoryWidget;
var actionContext = widgetDisplayContext.ActionContext;
int cate = actionContext.RouteData.GetCategory();
ProductCategory productCategory = null;
if (cate > 0)
{
productCategory = _productCategoryService.Get(cate);
}
if (actionContext.RouteData.GetCategoryUrl().IsNullOrEmpty() && productCategory != null)
后面还有 31 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。