fix: 修复审计日志判断当前用户为空的问题

This commit is contained in:
陈淳
2024-01-31 18:16:17 +08:00
parent c50f1ffcb4
commit ff19cb68b9
6 changed files with 110 additions and 7 deletions

View File

@@ -3,12 +3,17 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Level;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities.Integral;
using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.Bbs.Domain.Shared.Consts;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
@@ -20,9 +25,11 @@ namespace Yi.Framework.Bbs.Application.Services.Integral
public class LevelService : YiCrudAppService<LevelEntity, LevelOutputDto, Guid, LevelGetListInputDto>, ILevelService
{
private ISqlSugarRepository<LevelEntity, Guid> _repository;
public LevelService(ISqlSugarRepository<LevelEntity, Guid> repository) : base(repository)
private LevelManager _levelManager;
public LevelService(ISqlSugarRepository<LevelEntity, Guid> repository, LevelManager levelManager) : base(repository)
{
_repository= repository;
_repository = repository;
_levelManager = levelManager;
}
/// <summary>
@@ -35,11 +42,25 @@ namespace Yi.Framework.Bbs.Application.Services.Integral
RefAsync<int> total = 0;
var entities = await _repository._DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
.WhereIF(input.MinLevel is not null , x => x.CurrentLevel>=input.MinLevel)
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
.WhereIF(input.MinLevel is not null, x => x.CurrentLevel >= input.MinLevel)
.OrderBy(x => x.CurrentLevel)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<LevelOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
/// <summary>
/// 升级等级
/// </summary>
/// <returns></returns>
[Authorize]
public async Task UpdateUpgradeAsync(int experience)
{
if (experience <= 0)
{
throw new UserFriendlyException(LevelConst.Level_Low_Zero);
}
await _levelManager.ChangeLevelByMoneyAsync(CurrentUser.Id!.Value, experience);
}
}
}