修改一版
parent
2d5c0733c4
commit
310c526c8e
|
@ -186,6 +186,10 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpDelete("{readingQuestionSystemId:guid}")]
|
[HttpDelete("{readingQuestionSystemId:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteReadingQuestionSystem(Guid readingQuestionSystemId)
|
public async Task<IResponseOutput> DeleteReadingQuestionSystem(Guid readingQuestionSystemId)
|
||||||
{
|
{
|
||||||
|
if (await _readingQuestionSystemRepository.AnyAsync(x => x.ParentId == readingQuestionSystemId))
|
||||||
|
{
|
||||||
|
return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
|
||||||
|
}
|
||||||
await _readingQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionSystemId);
|
await _readingQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionSystemId);
|
||||||
var success = await _readingQuestionSystemRepository.SaveChangesAsync();
|
var success = await _readingQuestionSystemRepository.SaveChangesAsync();
|
||||||
return ResponseOutput.Result(success);
|
return ResponseOutput.Result(success);
|
||||||
|
@ -218,8 +222,56 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
List<ReadingQuestionSystem> systemQuestionList = x.ReadingQuestionSystemList.Clone();
|
List<ReadingQuestionSystem> systemQuestionList = x.ReadingQuestionSystemList.Clone();
|
||||||
|
|
||||||
|
List<ReadingQuestionTrial> readingQuestionTrialList = new List<ReadingQuestionTrial>();
|
||||||
|
|
||||||
|
SetChildParentQuestion(criterion.Id, trialId, systemQuestionList, readingQuestionTrialList);
|
||||||
|
|
||||||
|
|
||||||
|
needAddCriterionList.Add(criterion);
|
||||||
|
|
||||||
|
needAddQuestionList.AddRange(readingQuestionTrialList);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
await _readingQuestionCriterionTrialRepository.AddRangeAsync(needAddCriterionList);
|
||||||
|
|
||||||
|
await _readingQuestionTrialRepository.AddRangeAsync(needAddQuestionList);
|
||||||
|
|
||||||
|
await _readingQuestionTrialRepository.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置父子关系
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ReadingQuestionCriterionTrialId">项目标准ID</param>
|
||||||
|
/// <param name="trialId">项目Id</param>
|
||||||
|
/// <param name="systemQuesitonList">系统问题</param>
|
||||||
|
/// <param name="needQuestionList">需要添加list</param>
|
||||||
|
private void SetChildParentQuestion(Guid ReadingQuestionCriterionTrialId, Guid trialId, List<ReadingQuestionSystem> systemQuesitonList,List<ReadingQuestionTrial> needQuestionList)
|
||||||
|
{
|
||||||
|
var parentIdIsNullList = systemQuesitonList.Where(x => x.ParentId == null).ToList();
|
||||||
|
|
||||||
|
parentIdIsNullList.ForEach(x =>
|
||||||
|
{
|
||||||
|
var quesiton = x.Clone();
|
||||||
|
var oldId = quesiton.Id;
|
||||||
|
var newId = NewId.NextGuid();
|
||||||
|
needQuestionList.Add(new ReadingQuestionTrial()
|
||||||
|
{
|
||||||
|
Id = newId,
|
||||||
|
ShowOrder = quesiton.ShowOrder,
|
||||||
|
IsEnable = quesiton.IsEnable,
|
||||||
|
IsRequired = quesiton.IsRequired,
|
||||||
|
ParentTriggerValue = quesiton.ParentTriggerValue,
|
||||||
|
QuestionName = quesiton.QuestionName,
|
||||||
|
ReadingQuestionCriterionTrialId = ReadingQuestionCriterionTrialId,
|
||||||
|
TrialId = trialId,
|
||||||
|
Type = quesiton.Type,
|
||||||
|
TypeValue = quesiton.TypeValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateQuestionRelation(ReadingQuestionCriterionTrialId, trialId, oldId, newId, systemQuesitonList, needQuestionList);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,23 +279,44 @@ namespace IRaCIS.Application.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 递归处理父子问题关系
|
/// 递归处理父子关系
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task SetChildParentQuestion(Guid trialId, List<ReadingQuestionSystem> systemQuesitonList,List<ReadingQuestionTrial> needQuestionList)
|
/// <param name="ReadingQuestionCriterionTrialId"></param>
|
||||||
|
/// <param name="trialId"></param>
|
||||||
|
/// <param name="oldParentId"></param>
|
||||||
|
/// <param name="newParentId"></param>
|
||||||
|
/// <param name="systemQuesitonList"></param>
|
||||||
|
/// <param name="needQuestionList"></param>
|
||||||
|
public void CreateQuestionRelation(Guid ReadingQuestionCriterionTrialId, Guid trialId,Guid oldParentId,Guid newParentId, List<ReadingQuestionSystem> systemQuesitonList, List<ReadingQuestionTrial> needQuestionList)
|
||||||
{
|
{
|
||||||
var parentIdIsNullList = systemQuesitonList.Where(x => x.ParentId == null).ToList();
|
var childList = systemQuesitonList.Where(x => x.ParentId == oldParentId).ToList();
|
||||||
|
childList.ForEach(x =>
|
||||||
//parentIdIsNullList.ForEach(x => {
|
{
|
||||||
// var oldId = x.Id.Clone();`
|
var quesiton = x.Clone();
|
||||||
|
var oldId = quesiton.Id;
|
||||||
|
var newId = NewId.NextGuid();
|
||||||
//})
|
needQuestionList.Add(new ReadingQuestionTrial()
|
||||||
|
{
|
||||||
|
Id = newId,
|
||||||
|
ShowOrder = quesiton.ShowOrder,
|
||||||
|
IsEnable = quesiton.IsEnable,
|
||||||
|
IsRequired = quesiton.IsRequired,
|
||||||
|
ParentId = newParentId,
|
||||||
|
ParentTriggerValue = quesiton.ParentTriggerValue,
|
||||||
|
QuestionName = quesiton.QuestionName,
|
||||||
|
ReadingQuestionCriterionTrialId = ReadingQuestionCriterionTrialId,
|
||||||
|
TrialId = trialId,
|
||||||
|
Type = quesiton.Type,
|
||||||
|
TypeValue = quesiton.TypeValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateQuestionRelation(ReadingQuestionCriterionTrialId, trialId, oldId, newId, systemQuesitonList, needQuestionList);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增修改项目问题标准(项目)
|
/// 新增修改项目问题标准(项目)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -263,6 +336,7 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<PageOutput<ReadingQuestionCriterionTrialView>> GetReadingQuestionCriterionTrialList(ReadingQuestionCriterionTrialViewInDto inDto)
|
public async Task<PageOutput<ReadingQuestionCriterionTrialView>> GetReadingQuestionCriterionTrialList(ReadingQuestionCriterionTrialViewInDto inDto)
|
||||||
{
|
{
|
||||||
|
await AddSystemDataToTrila(inDto.TrialId);
|
||||||
var query = _readingQuestionCriterionTrialRepository.AsQueryable()
|
var query = _readingQuestionCriterionTrialRepository.AsQueryable()
|
||||||
.Where(x=>x.TrialId==inDto.TrialId)
|
.Where(x=>x.TrialId==inDto.TrialId)
|
||||||
.WhereIf(!inDto.CriterionName.IsNullOrEmpty(), x => x.CriterionName.Contains(inDto.CriterionName))
|
.WhereIf(!inDto.CriterionName.IsNullOrEmpty(), x => x.CriterionName.Contains(inDto.CriterionName))
|
||||||
|
@ -322,6 +396,10 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpDelete("{readingQuestionTrialId:guid}")]
|
[HttpDelete("{readingQuestionTrialId:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteReadingQuestionTrial(Guid readingQuestionTrialId)
|
public async Task<IResponseOutput> DeleteReadingQuestionTrial(Guid readingQuestionTrialId)
|
||||||
{
|
{
|
||||||
|
if (await _readingQuestionTrialRepository.AnyAsync(x => x.ParentId == readingQuestionTrialId))
|
||||||
|
{
|
||||||
|
return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
|
||||||
|
}
|
||||||
await _readingQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionTrialId);
|
await _readingQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionTrialId);
|
||||||
var success = await _readingQuestionTrialRepository.SaveChangesAsync();
|
var success = await _readingQuestionTrialRepository.SaveChangesAsync();
|
||||||
return ResponseOutput.Result(success);
|
return ResponseOutput.Result(success);
|
||||||
|
|
Loading…
Reference in New Issue