修改
This commit is contained in:
@@ -16,13 +16,15 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
public class QCQuestionConfigureService : BaseService, IQCQuestionService
|
||||
{
|
||||
private readonly IRepository<QCQuestion> _qcQuestionRepository;
|
||||
private readonly IRepository<TrialQCQuestion> _trialQCQuestionRepository;
|
||||
|
||||
public QCQuestionConfigureService(IRepository<QCQuestion> qcQuestionRepository)
|
||||
public QCQuestionConfigureService(IRepository<QCQuestion> qcQuestionRepository,
|
||||
IRepository<TrialQCQuestion> trialQCQuestionRepository
|
||||
|
||||
)
|
||||
{
|
||||
_qcQuestionRepository = qcQuestionRepository;
|
||||
|
||||
|
||||
|
||||
this._trialQCQuestionRepository = trialQCQuestionRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,14 +41,14 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
var initList = await _qcQuestionRepository
|
||||
.WhereIf(trialQCQuestionFilterSelect.TypeArray.Count() > 0, t => trialQCQuestionFilterSelect.TypeArray.Contains(t.Type))
|
||||
|
||||
.OrderBy(t => t.ShowOrder).Select(x=>new TrialQCQuestionSelect() {
|
||||
ShowOrder=x.ShowOrder,
|
||||
Id=x.Id,
|
||||
ParentId=x.ParentId,
|
||||
QuestionName=x.QuestionName,
|
||||
TypeValue=x.TypeValue,
|
||||
|
||||
.WhereIf(trialQCQuestionFilterSelect.Id != null, t => t.Id != trialQCQuestionFilterSelect.Id && t.ParentId != trialQCQuestionFilterSelect.Id)
|
||||
.OrderBy(t => t.ShowOrder).Select(x => new TrialQCQuestionSelect() {
|
||||
ShowOrder = x.ShowOrder,
|
||||
Id = x.Id,
|
||||
ParentId = x.ParentId,
|
||||
QuestionName = x.QuestionName,
|
||||
TypeValue = x.TypeValue,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
//父亲的序号肯定要比自己小
|
||||
@@ -92,7 +94,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
var QCQuestionQueryable = _qcQuestionRepository
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(queryQCQuestionConfigure.QuestionName), t => t.QuestionName.Contains(queryQCQuestionConfigure.QuestionName))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(queryQCQuestionConfigure.Type), t => t.Type.Contains(queryQCQuestionConfigure.Type))
|
||||
.WhereIf(queryQCQuestionConfigure.IsEnable!=null, t => t.IsEnable==queryQCQuestionConfigure.IsEnable)
|
||||
.WhereIf(queryQCQuestionConfigure.IsEnable != null, t => t.IsEnable == queryQCQuestionConfigure.IsEnable)
|
||||
.ProjectTo<QCQuestionConfigureView>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await QCQuestionQueryable.ToListAsync();
|
||||
@@ -118,5 +120,53 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取问题预览
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <remarks>
|
||||
/// 传TrialId为获取项目的
|
||||
/// 不传为获取系统的
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public async Task<List<QCQuestionView>> GetQuestionView(QCQuestionViewInDto inDto)
|
||||
{
|
||||
var question = new List<QCQuestionView>();
|
||||
if (inDto.TrialId== null)
|
||||
{
|
||||
question = await _trialQCQuestionRepository.Where(x => x.TrialId == inDto.TrialId).OrderBy(x => x.ShowOrder).ProjectTo<QCQuestionView>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
question=await _qcQuestionRepository.AsQueryable().OrderBy(x => x.ShowOrder).ProjectTo<QCQuestionView>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
var result = question.Where(x => x.ParentId == null).ToList();
|
||||
result.ForEach(x => {
|
||||
GetQuestionChild(x, question);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void GetQuestionChild(QCQuestionView parent, List<QCQuestionView> dataList)
|
||||
{
|
||||
parent.ChildList = dataList.Where(x => x.ParentId == parent.Id).ToList();
|
||||
|
||||
if (parent.ChildList.Count != 0)
|
||||
{
|
||||
parent.ChildList.ForEach(x =>
|
||||
{
|
||||
GetQuestionChild(x, dataList);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user