From 5bfeba991b242a078b418d2152cde93c572d9121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=98=8E=E9=94=8B?= Date: Tue, 27 Feb 2024 15:54:51 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=B8=8D=E8=B6=B3=E6=97=B6=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/AutoMapperConfiguration.cs | 4 ++-- src/OSharp.EntityFrameworkCore/Repository.cs | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) 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++)