This commit is contained in:
he
2022-08-11 15:02:40 +08:00
parent 728716256c
commit ea435f94b1
6 changed files with 268 additions and 5 deletions
@@ -8,7 +8,61 @@ using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public class ReadingTableQuestionSystemView
{
public Guid Id { get; set; }
public Guid ReadingQuestionId { get; set; }
public string Type { get; set; }
public Guid? ParentId { get; set; }
public string ParentTriggerValue { get; set; }
public string QuestionName { get; set; }
public int IsRequired { get; set; }
public int ShowOrder { get; set; }
public string TypeValue { get; set; }
public bool IsEnable { get; set; }
public DateTime CreateTime { get; set; }
public Guid CreateUserId { get; set; }
public string Remark { get; set; }
public Guid? RelevanceId { get; set; }
public string RelevanceValue { get; set; }
public int ShowQuestion { get; set; }
public int? MaxQuestionCount { get; set; }
public string DataTableName { get; set; }
public string DataTableColumn { get; set; }
}
public class ReadingTableQuestionSystemQuery
{
public Guid ReadingQuestionId { get; set; }
}
///<summary> ReadingTableQuestionSystemAddOrEdit 列表查询参数模型</summary>
public class ReadingTableQuestionSystemAddOrEdit
{
public Guid Id { get; set; }
public Guid ReadingQuestionId { get; set; }
public string Type { get; set; }
public Guid? ParentId { get; set; }
public string ParentTriggerValue { get; set; }
public string QuestionName { get; set; }
public int IsRequired { get; set; }
public int ShowOrder { get; set; }
public string TypeValue { get; set; }
public bool IsEnable { get; set; }
public DateTime CreateTime { get; set; }
public Guid CreateUserId { get; set; }
public string Remark { get; set; }
public Guid? RelevanceId { get; set; }
public string RelevanceValue { get; set; }
public int ShowQuestion { get; set; }
public int? MaxQuestionCount { get; set; }
public string DataTableName { get; set; }
public string DataTableColumn { get; set; }
}
public class ReadingCriterionPageView
{
@@ -484,6 +538,21 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public Guid? ReadingCriterionPageId { get; set; }
}
public class GetReadingTableOtherQuestionSystemInDto
{
/// <summary>
/// 表格父问题的ID
/// </summary>
[NotDefault]
public Guid ReadingQuestionId { get; set; }
/// <summary>
/// 当前ID
/// </summary>
public Guid? Id { get; set; }
}
public class GetTrialCriterionOtherQuestionInDto
{
[NotDefault]
@@ -33,7 +33,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<Dictionary> _dictionaryRepository;
private readonly IRepository<ReadingCriterionPage> _readingCriterionPageRepository;
private readonly IRepository<Trial> _trialRepository;
private readonly IRepository<ReadingTableQuestionSystem> _readingTableQuestionSystemRepository;
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswer;
private readonly IRepository<PreviousPDF> _previousPDFRepository;
@@ -48,7 +48,7 @@ namespace IRaCIS.Application.Services
IRepository<Dictionary> dictionaryRepository,
IRepository<ReadingCriterionPage> readingCriterionPageRepository,
IRepository<Trial> trialRepository,
IRepository<ReadingTableQuestionSystem> readingTableQuestionSystemRepository,
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswer,
IRepository<PreviousPDF> previousPDFRepository
)
@@ -63,11 +63,89 @@ namespace IRaCIS.Application.Services
this._dictionaryRepository = dictionaryRepository;
this._readingCriterionPageRepository = readingCriterionPageRepository;
this._trialRepository = trialRepository;
this._readingTableQuestionSystemRepository = readingTableQuestionSystemRepository;
this._readingTaskQuestionAnswer = readingTaskQuestionAnswer;
this._previousPDFRepository = previousPDFRepository;
}
/// <summary>
/// 获取系统的表格问题
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<List<ReadingTableQuestionSystemView>> GetReadingTableQuestionSystemList(ReadingTableQuestionSystemQuery inDto)
{
var readingTableQuestionSystemQueryable = _readingTableQuestionSystemRepository
.Where(x=>x.ReadingQuestionId==inDto.ReadingQuestionId).ProjectTo<ReadingTableQuestionSystemView>(_mapper.ConfigurationProvider);
var result=await readingTableQuestionSystemQueryable.ToListAsync();
return result;
}
/// <summary>
/// 新增修改系统表格问题
/// </summary>
/// <param name="addOrEditReadingTableQuestionSystem"></param>
/// <returns></returns>
public async Task<IResponseOutput> AddOrUpdateReadingTableQuestionSystem(ReadingTableQuestionSystemAddOrEdit addOrEditReadingTableQuestionSystem)
{
var entity = await _readingTableQuestionSystemRepository.InsertOrUpdateAsync(addOrEditReadingTableQuestionSystem, true);
return ResponseOutput.Ok(entity.Id.ToString());
}
/// <summary>
/// 删除系统表格问题
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpDelete("{Id:guid}")]
public async Task<IResponseOutput> DeleteReadingTableQuestionSystem(Guid Id)
{
if(await _readingTableQuestionSystemRepository.AnyAsync(x=>x.ParentId==Id||x.RelevanceId==Id))
{
return ResponseOutput.NotOk("当前问题存在子问题 删除失败");
}
await _readingTableQuestionSystemRepository.BatchDeleteNoTrackingAsync(t => t.Id == Id);
var success= await _readingTableQuestionSystemRepository.SaveChangesAsync();
return ResponseOutput.Result(success);
}
/// <summary>
/// 获取系统表格其他问题
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<List<CriterionOtherQuestionOutDto>> GetReadingTableOtherQuestionSystem(GetReadingTableOtherQuestionSystemInDto inDto)
{
var types = new List<string>()
{
"select","radio"
};
var questionList = await _readingTableQuestionSystemRepository.Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId)
.Where(x => types.Contains(x.Type))
.WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
.Select(x => new CriterionOtherQuestionOutDto()
{
QuestionId = x.Id,
QuestionName = x.QuestionName,
TypeValue = x.TypeValue,
}).ToListAsync();
return questionList;
}
/// <summary>
/// 设置项目裁判信息
/// </summary>
@@ -51,8 +51,10 @@ namespace IRaCIS.Core.Application.Service
#region
CreateMap<ReadingTableQuestionSystem, ReadingTableQuestionSystemView>();
CreateMap<ReadingTableQuestionSystemAddOrEdit, ReadingTableQuestionSystem>();
CreateMap<ReadingCriterionPageAddOrEdit, ReadingCriterionPage>();
CreateMap<ReadingQuestionTrial, ReadingQuestionSystem>();