修改仓储

Uat_Study
he 2022-04-25 14:16:40 +08:00
parent 2d25ebd7ce
commit 9d5108e683
4 changed files with 11 additions and 13 deletions

View File

@ -566,6 +566,7 @@ namespace IRaCIS.Application.Services
});
await _inspectionService.AddListInspectionRecordAsync(datas);
await _repository.AddAsync(stat);
//await _subjectVisitRepository.AddRangeAsync()
await _repository.AddRangeAsync(subjectVisits);
await _repository.SaveChangesAsync();
return ResponseOutput.Ok();

View File

@ -10,7 +10,7 @@ namespace IRaCIS.Core.Domain.Common
public static class JJsonConvert
{
/// <summary>
/// 将对象序列化成Json字符串
/// 将对象序列化成稽查需要的Json字符串
/// </summary>
/// <param name="obj">需要序列化的对象</param>
/// <param name="jsonConverterArray"></param>

View File

@ -53,9 +53,9 @@ namespace IRaCIS.Core.Infra.EFCore
Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null, bool ignoreQueryFilters = false);
ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default,bool isSaveAudit=false);
Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities);
Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities, bool isSaveAudit = false);
//Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
// 不建议使用使用跟踪然后save 部分字段更新,此种方式是更新所有字段

View File

@ -19,6 +19,7 @@ using Microsoft.Data.SqlClient;
using Newtonsoft.Json;
using IRaCIS.Core.Infra.EFCore.Dto;
using Newtonsoft.Json.Linq;
using IRaCIS.Core.Domain.Common;
namespace IRaCIS.Core.Infra.EFCore
{
@ -42,28 +43,24 @@ namespace IRaCIS.Core.Infra.EFCore
}
#region 异步 EF 跟踪 添加
public async Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities)
public async Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities,bool isSaveAudit=false)
{
foreach (var addEntity in entities)
{
await AddAsync(addEntity);
await AddAsync(addEntity, isSaveAudit);
}
return entities;
}
/// <summary>EF跟踪方式 添加</summary>
public async ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
public async ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default,bool isSaveAudit=false)
{
await _dbSet.AddAsync(entity).ConfigureAwait(false);
await AddInspectionAsync(entity);
await AddInspectionAsync(entity, isSaveAudit);
if (autoSave)
{
@ -583,7 +580,7 @@ namespace IRaCIS.Core.Infra.EFCore
}
private async Task AddInspectionAsync(TEntity entity)
private async Task AddInspectionAsync(TEntity entity,bool isSaveAudit=false)
{
List<DataInspection> datas = new List<DataInspection>();
@ -602,7 +599,7 @@ namespace IRaCIS.Core.Infra.EFCore
IsSign = false,
CreateTime = createtime,
Identification = "Init|Subject|Status|Subject",
JsonDetail = JsonConvert.SerializeObject(entity)
JsonDetail = entity.ToJcJson()
});
}
await AddListInspectionRecordAsync(datas);