mahjong_group/server/CoreCms.Net.Services/WeChat/CoreCmsUserWeChatMsgTemplateServices.cs
2026-01-01 14:35:52 +08:00

66 lines
2.8 KiB
C#

/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
namespace CoreCms.Net.Services
{
/// <summary>
/// 微信小程序消息模板 接口实现
/// </summary>
public class CoreCmsUserWeChatMsgTemplateServices : BaseServices<CoreCmsUserWeChatMsgTemplate>, ICoreCmsUserWeChatMsgTemplateServices
{
private readonly ICoreCmsUserWeChatMsgTemplateRepository _dal;
private readonly IUnitOfWork _unitOfWork;
private readonly IRedisOperationRepository _redisOperationRepository;
public CoreCmsUserWeChatMsgTemplateServices(IUnitOfWork unitOfWork, ICoreCmsUserWeChatMsgTemplateRepository dal,
IRedisOperationRepository redisOperationRepository
)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
_redisOperationRepository = redisOperationRepository;
}
public async Task<List<CoreCmsUserWeChatMsgTemplate>> GetListAsync()
{
var key = $"cache:CoreCmsUserWeChatMsgTemplate";
var list = await _redisOperationRepository.Get<List<CoreCmsUserWeChatMsgTemplate>>(key);
if (list == null)
{
List<string> strings = new
List<string>{
GlobalEnumVars.WeChatMsgTemplateType.reservation_success.ToString(),
GlobalEnumVars.WeChatMsgTemplateType.reservation_change.ToString(),
GlobalEnumVars.WeChatMsgTemplateType.reservation_reminder.ToString(),
GlobalEnumVars.WeChatMsgTemplateType.reservation_notice.ToString(),
GlobalEnumVars.WeChatMsgTemplateType.deduction_notice.ToString(),
GlobalEnumVars.WeChatMsgTemplateType.refund.ToString(),
};
list = await _dal.QueryListByClauseAsync(it => strings.Contains(it.templateTitle));
await _redisOperationRepository.Set(key, list, TimeSpan.FromMinutes(10));
}
return list;
}
}
}