Skip to content

Commit

Permalink
wip: 更新数据权限不足时的提示语
Browse files Browse the repository at this point in the history
  • Loading branch information
gmf520 committed Feb 27, 2024
1 parent 703892a commit 5bfeba9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class AutoMapperConfiguration : AutoMapperTupleBase
/// </summary>
public override void CreateMap()
{
CreateMap<EntityRoleInputDto, EntityRole>()
.ForMember(mr => mr.FilterGroupJson, opt => opt.MapFrom(dto => dto.FilterGroup.ToJsonString(false, false)));
//CreateMap<EntityRoleInputDto, EntityRole>()
// .ForMember(mr => mr.FilterGroupJson, opt => opt.MapFrom(dto => dto.FilterGroup.ToJsonString(false, false)));

//mapper.CreateMap<EntityRole, EntityRoleOutputDto>()
// .ForMember(dto => dto.FilterGroup, opt => opt.ResolveUsing(mr => mr.FilterGroupJson?.FromJsonString<FilterGroup>()));
Expand Down
19 changes: 10 additions & 9 deletions src/OSharp.EntityFrameworkCore/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,8 @@ public virtual async Task<int> DeleteBatchAsync(Expression<Func<TEntity, bool>>
{
// 物理删除
count = await _dbSet.Where(predicate).DeleteAsync(_cancellationTokenProvider.Token);
}
}

await unitOfWork.CommitAsync(_cancellationTokenProvider.Token);
return count;
}
Expand Down Expand Up @@ -828,8 +828,8 @@ public virtual async Task<int> UpdateBatchAsync(Expression<Func<TEntity, bool>>

//走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;
}
Expand Down Expand Up @@ -937,15 +937,16 @@ private void CheckDataAuth(DataAuthOperation operation, params TEntity[] entitie
if (entities.Length == 0 || _dataAuthService == null)
{
return;
}
}

bool flag = _dataAuthService.CheckDataAuth<TEntity>(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++)
Expand Down

0 comments on commit 5bfeba9

Please sign in to comment.