src/ZKEACMS.Article/Service/ArticleGalleryWidgetDataService.cs
(完整代码) 1KB/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using Easy.Extend;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZKEACMS.Article.Models;
using ZKEACMS.Widget;
namespace ZKEACMS.Article.Service
{
public class ArticleGalleryWidgetDataService : IArticleGalleryWidgetDataService
{
private readonly IWidgetBasePartService _widgetBasePartService;
public ArticleGalleryWidgetDataService(IWidgetBasePartService widgetBasePartService)
{
_widgetBasePartService = widgetBasePartService;
}
public void UpdateDetailPageUrl(string oldUrl, string newUrl)
{
var widgets = _widgetBasePartService.GetAllWidgets<ArticleGalleryWidgetService, ArticleGalleryWidget>();
List<ArticleGalleryWidget> needUpdateWidgets = new List<ArticleGalleryWidget>();
foreach (var item in widgets)
{
if (item.DetailPageUrl.IsNullOrEmpty()) continue;
if (item.DetailPageUrl.Equals(oldUrl, StringComparison.OrdinalIgnoreCase) ||
item.DetailPageUrl.StartsWith(oldUrl + "/", StringComparison.OrdinalIgnoreCase))
{
item.DetailPageUrl = newUrl + item.DetailPageUrl.Substring(oldUrl.Length);
needUpdateWidgets.Add(item);
}
}
if (needUpdateWidgets.Any())
{
_widgetBasePartService.UpdateWidgets(needUpdateWidgets.ToArray());
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。