diff --git a/samples/web/Liuliu.Demo.Core/Authorization/Dtos/AutoMapperConfiguration.cs b/samples/web/Liuliu.Demo.Core/Authorization/Dtos/AutoMapperConfiguration.cs index 2a26737e..cb4a13f1 100644 --- a/samples/web/Liuliu.Demo.Core/Authorization/Dtos/AutoMapperConfiguration.cs +++ b/samples/web/Liuliu.Demo.Core/Authorization/Dtos/AutoMapperConfiguration.cs @@ -27,8 +27,8 @@ public class AutoMapperConfiguration : AutoMapperTupleBase /// public override void CreateMap() { - CreateMap() - .ForMember(mr => mr.FilterGroupJson, opt => opt.MapFrom(dto => dto.FilterGroup.ToJsonString(false, false))); + //CreateMap() + // .ForMember(mr => mr.FilterGroupJson, opt => opt.MapFrom(dto => dto.FilterGroup.ToJsonString(false, false))); //mapper.CreateMap() // .ForMember(dto => dto.FilterGroup, opt => opt.ResolveUsing(mr => mr.FilterGroupJson?.FromJsonString())); diff --git a/src/OSharp.EntityFrameworkCore/Repository.cs b/src/OSharp.EntityFrameworkCore/Repository.cs index 718bc140..cfba552f 100644 --- a/src/OSharp.EntityFrameworkCore/Repository.cs +++ b/src/OSharp.EntityFrameworkCore/Repository.cs @@ -734,8 +734,8 @@ public virtual async Task DeleteBatchAsync(Expression> { // 物理删除 count = await _dbSet.Where(predicate).DeleteAsync(_cancellationTokenProvider.Token); - } - + } + await unitOfWork.CommitAsync(_cancellationTokenProvider.Token); return count; } @@ -828,8 +828,8 @@ public virtual async Task UpdateBatchAsync(Expression> //走EF.Plus的时候,是不调用SaveChanges的,需要手动开启事务 await ((DbContextBase)_dbContext).BeginOrUseTransactionAsync(_cancellationTokenProvider.Token); - int count = await _dbSet.Where(predicate).UpdateAsync(updateExpression, _cancellationTokenProvider.Token); - + int count = await _dbSet.Where(predicate).UpdateAsync(updateExpression, _cancellationTokenProvider.Token); + await unitOfWork.CommitAsync(_cancellationTokenProvider.Token); return count; } @@ -937,15 +937,16 @@ private void CheckDataAuth(DataAuthOperation operation, params TEntity[] entitie if (entities.Length == 0 || _dataAuthService == null) { return; - } - + } + bool flag = _dataAuthService.CheckDataAuth(operation, entities); if (!flag) { - throw new OsharpException($"实体 {typeof(TEntity).Name} 的数据 {entities.ExpandAndToString(m => m.Id.ToString())} 进行 {operation.ToDescription()} 操作时权限不足"); + throw new OsharpException( + $"{operation.ToDescription()}编号为 {entities.ExpandAndToString(m => m.Id.ToString())} 的 {typeof(TEntity).GetDescription()} 时操作权限不足(403)"); } - } - + } + private TEntity[] CheckInsert(params TEntity[] entities) { for (int i = 0; i < entities.Length; i++)