src/SSCMS.Core/Repositories/ContentRepository.Delete.cs

(开头部分) 10KB

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Datory;
using SSCMS.Core.Utils;
using SSCMS.Enums;
using SSCMS.Models;
using SSCMS.Plugins;
using SSCMS.Services;

namespace SSCMS.Core.Repositories
{
    public partial class ContentRepository
    {
        public async Task TrashContentsAsync(Site site, Channel channel, List<int> contentIdList, int adminId)
        {
            if (contentIdList == null || !contentIdList.Any()) return;

            var repository = await GetRepositoryAsync(site, channel);

            var cacheKeys = new List<string>
            {
                GetListKey(repository.TableName, site.Id, channel.Id)
            };
            foreach (var contentId in contentIdList)
            {
                cacheKeys.Add(GetEntityKey(repository.TableName, contentId));
            }

            var referenceSummaries = await GetReferenceIdListAsync(repository.TableName, contentIdList);
            if (referenceSummaries.Count > 0)
            {
                foreach (var referenceSummary in referenceSummaries)
                {
                    await DeleteReferenceContentsAsync(site, referenceSummary);
                }
            }

            var channelIdName = repository.Database.GetQuotedIdentifier(nameof(Content.ChannelId));
            await repository.UpdateAsync(
                GetQuery(site.Id, channel.Id)
                    .SetRaw($"{channelIdName} = -{channelIdName}")
                    .Set(nameof(Content.LastEditAdminId), adminId)
                    .WhereIn(nameof(Content.Id), contentIdList)
                    .CachingRemove(cacheKeys.ToArray())
            );
        }

        public async Task TrashContentsAsync(Site site, int channelId, int adminId)
        {
            var channelIds = await _channelRepository.GetChannelIdsAsync(site.Id, channelId, ScopeType.All);
            foreach (var selectedId in channelIds)
            {
                var selected = await _channelRepository.GetAsync(selectedId);
                var contentIds = await GetContentIdsAsync(site, selected);
                await TrashContentsAsync(site, selected, contentIds, adminId);
            }
        }

后面还有 202 行代码,解锁后查看完整代码

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

AI 解读

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

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