From b30e2f0cc096a10ffdffdd25ad672cf321bb029d Mon Sep 17 00:00:00 2001 From: chenchun Date: Fri, 9 Aug 2024 10:50:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AD=89=E7=BA=A7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Managers/LevelManager.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/LevelManager.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/LevelManager.cs index 99dff626..fb9e9806 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/LevelManager.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/LevelManager.cs @@ -1,4 +1,5 @@ using Mapster; +using Microsoft.Extensions.Caching.Distributed; using Volo.Abp.Caching; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; @@ -8,6 +9,7 @@ using Yi.Framework.Bbs.Domain.Entities.Integral; using Yi.Framework.Bbs.Domain.Shared.Caches; using Yi.Framework.Bbs.Domain.Shared.Consts; using Yi.Framework.Bbs.Domain.Shared.Etos; +using Yi.Framework.SqlSugarCore.Abstractions; namespace Yi.Framework.Bbs.Domain.Managers { @@ -16,9 +18,9 @@ namespace Yi.Framework.Bbs.Domain.Managers private ILocalEventBus _localEventBus; private IDistributedCache> _levelCache; private IRepository _repository; - private IRepository _bbsUserRepository; + private ISqlSugarRepository _bbsUserRepository; public LevelManager( ILocalEventBus localEventBus, - IDistributedCache> levelCache, IRepository repository, IRepository bbsUserRepository) + IDistributedCache> levelCache, IRepository repository, ISqlSugarRepository bbsUserRepository) { _localEventBus = localEventBus; _repository = repository; @@ -33,9 +35,9 @@ namespace Yi.Framework.Bbs.Domain.Managers /// public async Task> GetCacheMapAsync() { - var items =await _levelCache.GetOrAddAsync(LevelConst.LevelCacheKey, async () => + var items = _levelCache.GetOrAdd(LevelConst.LevelCacheKey, () => { - var cacheItem = (await _repository.GetListAsync()) + var cacheItem = ( _repository.GetListAsync().Result) .OrderByDescending(x => x.CurrentLevel).ToList() .Adapt>(); return cacheItem; @@ -71,10 +73,13 @@ namespace Yi.Framework.Bbs.Domain.Managers break; } } - + + //这里注意,只更新等级 userInfo.Level = currentNewLevel; userInfo.Experience = currentNewExperience; - await _bbsUserRepository.UpdateAsync(userInfo); + await _bbsUserRepository._Db.Updateable(userInfo) + .UpdateColumns(it => new { it.Level,it.Experience }) + .ExecuteCommandAsync(); } } } \ No newline at end of file