对接修改
parent
a85c2d1316
commit
a89b69e1f8
|
@ -98,6 +98,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
[HttpDelete("{trialId:guid}/{id:guid}")]
|
||||
[TypeFilter(typeof(TrialResourceFilter))]
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> DeleteSubject(Guid id)
|
||||
{
|
||||
|
||||
|
@ -106,12 +107,11 @@ namespace IRaCIS.Application.Services
|
|||
return ResponseOutput.NotOk("This subject has executed a visit with uploading study images,and couldn't be deleted.");
|
||||
}
|
||||
|
||||
await _subjectRepository.DeleteFromQueryAsync(u => u.Id == id);
|
||||
await _subjectVisitRepository.DeleteFromQueryAsync(u => u.SubjectId == id);
|
||||
await _subjectRepository.SoftDeleteFromQueryAsync(u => u.Id == id);
|
||||
await _subjectVisitRepository.SoftDeleteFromQueryAsync(u => u.SubjectId == id);
|
||||
|
||||
var isSuccess = await _subjectRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
return ResponseOutput.Result(isSuccess);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using IRaCIS.Core.Infrastructure.ExpressionExtend;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
|
@ -23,22 +22,16 @@ namespace IRaCIS.Application.Services
|
|||
private readonly IRepository<VisitStage> _visitStageRepository;
|
||||
private readonly IRepository<Trial> _trialRepository;
|
||||
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
||||
private readonly IRepository<VisitPlanInfluenceStat> _influnceStatRepository;
|
||||
private readonly IRepository<VisitPlanInfluenceStudy> _influnceRepository;
|
||||
private readonly IInspectionService _inspectionService;
|
||||
|
||||
public VisitPlanService(IRepository<VisitStage> visitStageRepository, IRepository<Trial> trialRepository, IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<VisitPlanInfluenceStat> influnceStatRepository,
|
||||
IRepository<VisitPlanInfluenceStudy> visitPlanInfluenceStudy,
|
||||
|
||||
IInspectionService inspectionService)
|
||||
IRepository<VisitPlanInfluenceStudy> visitPlanInfluenceStudy)
|
||||
{
|
||||
_visitStageRepository = visitStageRepository;
|
||||
_trialRepository = trialRepository;
|
||||
this._subjectVisitRepository = subjectVisitRepository;
|
||||
this._influnceStatRepository = influnceStatRepository;
|
||||
this._influnceRepository = visitPlanInfluenceStudy;
|
||||
this._inspectionService = inspectionService;
|
||||
}
|
||||
|
||||
|
||||
|
@ -355,7 +348,7 @@ namespace IRaCIS.Application.Services
|
|||
//访视计划 整体状态变更为 确认
|
||||
await _visitStageRepository.BatchUpdateNoTrackingAsync(u => u.TrialId == trialId, t => new VisitStage() { IsConfirmed = true, IsHaveFirstConfirmed = true });
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
await _visitStageRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
|
@ -389,6 +382,8 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary> 删除项目计划某一项 废弃 </summary>
|
||||
[HttpDelete("{id:guid}/{trialId:guid}")]
|
||||
[TrialAudit(AuditType.TrialAudit, AuditOptType.DeleteTrialVisitPlanItem)]
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
/// <summary>批量删除,EF跟踪方式(所有查询出来,再删除 浪费性能,但是稽查 或者触发某些操作时,需要知道数据库实体信息 不可避免用这种)</summary>
|
||||
Task<List<TEntity>> DeleteFromQueryAsync(Expression<Func<TEntity, bool>> deleteFilter, bool autoSave = false, bool ignoreQueryFilter = false);
|
||||
|
||||
Task<List<TEntity>> SoftDeleteFromQueryAsync(Expression<Func<TEntity, bool>> deleteFilter, bool autoSave = false, bool ignoreQueryFilter = false);
|
||||
|
||||
Task<TEntity> DeleteFromQueryAsync(Guid id, bool autoSave = false, bool ignoreQueryFilter = false);
|
||||
|
||||
|
||||
|
|
|
@ -355,6 +355,24 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
}
|
||||
|
||||
public async Task<List<TEntity>> SoftDeleteFromQueryAsync(Expression<Func<TEntity, bool>> deleteFilter, bool autoSave = false, bool ignoreQueryFilter = false)
|
||||
{
|
||||
var query = ignoreQueryFilter ? _dbSet.IgnoreQueryFilters() : _dbSet;
|
||||
var waitDeleteList = await query.Where(deleteFilter).ToListAsync();
|
||||
|
||||
foreach (var deleteItem in waitDeleteList)
|
||||
{
|
||||
if(deleteItem is ISoftDelete softDeleteItem)
|
||||
{
|
||||
softDeleteItem.IsDeleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
await SaveChangesAsync(autoSave);
|
||||
|
||||
return waitDeleteList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue