Files
Yi.Admin/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/YiFrameworkBbsDomainModule.cs

38 lines
1.5 KiB
C#
Raw Normal View History

2024-01-29 11:20:40 +08:00
using System.Collections.Generic;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
2024-03-18 09:51:02 +08:00
using Microsoft.Extensions.Logging;
2024-01-29 11:20:40 +08:00
using Volo.Abp;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Modularity;
using Yi.Framework.Bbs.Domain.Entities.Integral;
2023-12-11 09:55:12 +08:00
using Yi.Framework.Bbs.Domain.Shared;
2024-01-29 11:20:40 +08:00
using Yi.Framework.Bbs.Domain.Shared.Caches;
using Yi.Framework.Bbs.Domain.Shared.Consts;
2023-12-11 09:55:12 +08:00
using Yi.Framework.Rbac.Domain;
namespace Yi.Framework.Bbs.Domain
{
[DependsOn(
typeof(YiFrameworkBbsDomainSharedModule),
typeof(YiFrameworkRbacDomainModule)
)]
public class YiFrameworkBbsDomainModule : AbpModule
{
2024-01-29 11:20:40 +08:00
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
{
//加载等级缓存
var services = context.ServiceProvider;
2024-03-18 09:51:02 +08:00
var logger = services.GetRequiredService<ILogger<YiFrameworkBbsDomainModule>>();
logger.LogInformation("正在初始化【BBS-等级数据】......");
2024-01-29 11:20:40 +08:00
var levelRepository = services.GetRequiredService<IRepository<LevelEntity>>();
var levelCache = services.GetRequiredService<IDistributedCache<List<LevelCacheItem>>>();
var cacheItem = (await levelRepository.GetListAsync()).Adapt<List<LevelCacheItem>>();
await levelCache.SetAsync(LevelConst.LevelCacheKey, cacheItem);
2024-03-18 09:51:02 +08:00
logger.LogInformation("已完成初始化【BBS-等级数据】");
2024-01-29 11:20:40 +08:00
}
2023-12-11 09:55:12 +08:00
}
}