|
@@ -75,6 +75,18 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
extractRuleDto.RuleTagDtos = await GetRuleTagDtos(entityQueryRequest);
|
|
|
|
|
|
extractRuleDto.TagQuestionDtos = await GetTagQuestions(entityQueryRequest);
|
|
|
+
|
|
|
+ var tagQuestionCounts = await GetTagQuestionCountAsync(new TagQuestionRequest
|
|
|
+ {
|
|
|
+ TagIds = extractRuleDto.RuleTagDtos.Select(x=>x.TagId).ToList()
|
|
|
+ });
|
|
|
+
|
|
|
+ extractRuleDto.TagQuestionDtos.ForEach(item =>
|
|
|
+ {
|
|
|
+ var tagQuestionCount = tagQuestionCounts.FirstOrDefault(m => m.TagId == item.TagId);
|
|
|
+
|
|
|
+ item.TotalCount = tagQuestionCount?.TotalCount ?? 0;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -207,21 +219,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
public async Task<List<TagQuestionViewResponse>> GetTagQuestionCount(TagQuestionRequest tagQuestionRequest)
|
|
|
{
|
|
|
if (tagQuestionRequest.TagIds.IsNullOrEmpty()) return new List<TagQuestionViewResponse>();
|
|
|
-
|
|
|
- var expression = tagQuestionRequest.GetExpression();
|
|
|
- var questionTagTable = new ExamRepository<ExamQuestionTag>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(expression);
|
|
|
- var questionTable = new ExamRepository<ExamQuestion>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
- var queryable = questionTagTable.LeftJoin(questionTable, (t, q) => t.QuestionId == q.Id)
|
|
|
- .GroupBy((t, q) => new { t.TagId, q.QuestionType })
|
|
|
- .OrderBy((t, q) => t.TagId)
|
|
|
- .Select((t, q) => new TagQuestionViewResponse
|
|
|
- {
|
|
|
- TagId = t.TagId,
|
|
|
- QuestionType = q.QuestionType,
|
|
|
- TotalCount = SqlFunc.AggregateCount(q.Id!=null)
|
|
|
- });
|
|
|
-
|
|
|
- return await queryable.ToListAsync();
|
|
|
+ return await GetTagQuestionCountAsync(tagQuestionRequest);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -528,6 +526,24 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
actionRequest.RuleTagDtos.ForEach(x => x.RuleId = id);
|
|
|
}
|
|
|
+
|
|
|
+ private async Task<List<TagQuestionViewResponse>> GetTagQuestionCountAsync(TagQuestionRequest tagQuestionRequest)
|
|
|
+ {
|
|
|
+ var expression = tagQuestionRequest.GetExpression();
|
|
|
+ var questionTagTable = new ExamRepository<ExamQuestionTag>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(expression);
|
|
|
+ var questionTable = new ExamRepository<ExamQuestion>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
+ var queryable = questionTagTable.LeftJoin(questionTable, (t, q) => t.QuestionId == q.Id)
|
|
|
+ .GroupBy((t, q) => new { t.TagId, q.QuestionType })
|
|
|
+ .OrderBy((t, q) => t.TagId)
|
|
|
+ .Select((t, q) => new TagQuestionViewResponse
|
|
|
+ {
|
|
|
+ TagId = t.TagId,
|
|
|
+ QuestionType = q.QuestionType,
|
|
|
+ TotalCount = SqlFunc.AggregateCount(q.Id != null)
|
|
|
+ });
|
|
|
+
|
|
|
+ return await queryable.ToListAsync();
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|