src/SSCMS.Core/Repositories/WxReplyKeywordRepository.cs

(开头部分) 2KB

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

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

namespace SSCMS.Core.Repositories
{
    public class WxReplyKeywordRepository : IWxReplyKeywordRepository
    {
        private readonly Repository<WxReplyKeyword> _repository;

        public WxReplyKeywordRepository(ISettingsManager settingsManager)
        {
            _repository = new Repository<WxReplyKeyword>(settingsManager.Database, settingsManager.Redis);
        }

        public IDatabase Database => _repository.Database;

        public string TableName => _repository.TableName;

        public List<TableColumn> TableColumns => _repository.TableColumns;

        private string GetCacheKey(int siteId) => CacheUtils.GetListKey(_repository.TableName, siteId);

        public async Task<int> InsertAsync(WxReplyKeyword keyword)
        {
            return await _repository.InsertAsync(keyword, Q
                .CachingRemove(GetCacheKey(keyword.SiteId))
            );
        }

        public async Task UpdateAsync(WxReplyKeyword keyword)
        {
            await _repository.UpdateAsync(keyword, Q
                .CachingRemove(GetCacheKey(keyword.SiteId))
            );
        }

        public async Task DeleteAllAsync(int siteId, int ruleId)
        {
            await _repository.DeleteAsync(Q
                .Where(nameof(WxReplyKeyword.SiteId), siteId)
                .Where(nameof(WxReplyKeyword.RuleId), ruleId)
                .CachingRemove(GetCacheKey(siteId))
            );
        }

        public async Task<List<WxReplyKeyword>> GetKeywordsAsync(int siteId, int ruleId)
        {
            var allKeywords = await GetKeywordsAsync(siteId);
            return allKeywords.Where(x => x.RuleId == ruleId).ToList();
        }

        public async Task<List<WxReplyKeyword>> GetKeywordsAsync(int siteId)
        {
            return await _repository.GetAllAsync(Q
后面还有 6 行代码,解锁后查看完整代码

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

AI 解读

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

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