田爽 пре 1 година
родитељ
комит
f644a36a5b
1 измењених фајлова са 19 додато и 5 уклоњено
  1. 19 5
      src/Hotline.Api/Controllers/KnowledgeController.cs

+ 19 - 5
src/Hotline.Api/Controllers/KnowledgeController.cs

@@ -958,11 +958,18 @@ namespace Hotline.Api.Controllers
         [HttpGet("knowledge_correction/list")]
         public async Task<PagedDto<KnowledgeCorrectionDto>> List([FromQuery] KnowledgeCorrectionListDto dto)
         {
-            var (total, items) = await _knowledgeCorrectionRepository.Queryable()
+            var typeSpliceName = string.Empty;
+			if (!string.IsNullOrEmpty(dto.KnowledgeTypeId))
+	        {
+		        var type = await _knowledgeTypeRepository.GetAsync(x => x.Id == dto.KnowledgeTypeId);
+		        typeSpliceName = type?.SpliceName;
+	        }
+			var (total, items) = await _knowledgeCorrectionRepository.Queryable()
                 .Includes(x => x.Knowledge)
                 //.WhereIF(!string.IsNullOrEmpty(dto.KnowledgeTypeId), x => x.Knowledge.KnowledgeTypeId == dto.KnowledgeTypeId!)
                 .WhereIF(!string.IsNullOrEmpty(dto.CreatorName), x => x.CreatorName == dto.CreatorName!)
-                .Where(x => !string.IsNullOrEmpty(x.Knowledge.Id))
+                .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => SqlFunc.JsonLike(x.Knowledge.KnowledgeType, typeSpliceName))
+				.Where(x => !string.IsNullOrEmpty(x.Knowledge.Id))
                 .OrderByDescending(x => x.CreationTime)
                 .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
             return new PagedDto<KnowledgeCorrectionDto>(total, _mapper.Map<IReadOnlyList<KnowledgeCorrectionDto>>(items));
@@ -1055,10 +1062,17 @@ namespace Hotline.Api.Controllers
         [HttpGet("knowledge_questions/list")]
         public async Task<PagedDto<KnowledgeQuestionsDto>> List([FromQuery] KnowledgeQuestionsListDto dto)
         {
-            var (total, items) = await _knowledgeQuestionsRepository.Queryable()
+	        var typeSpliceName = string.Empty;
+	        if (!string.IsNullOrEmpty(dto.KnowledgeTypeId))
+	        {
+		        var type = await _knowledgeTypeRepository.GetAsync(x => x.Id == dto.KnowledgeTypeId);
+		        typeSpliceName = type?.SpliceName;
+	        }
+			var (total, items) = await _knowledgeQuestionsRepository.Queryable()
                 .Includes(x => x.Knowledge)
-                //.WhereIF(!string.IsNullOrEmpty(dto.KnowledgeTypeId), x => x.Knowledge.KnowledgeTypeId == dto.KnowledgeTypeId!)
-                .WhereIF(!string.IsNullOrEmpty(dto.CreatorName), x => x.CreatorName == dto.CreatorName!)
+				 //.WhereIF(!string.IsNullOrEmpty(dto.KnowledgeTypeId), x => x.Knowledge.KnowledgeTypeId == dto.KnowledgeTypeId!)
+				.WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => SqlFunc.JsonLike(x.Knowledge.KnowledgeType, typeSpliceName))
+				.WhereIF(!string.IsNullOrEmpty(dto.CreatorName), x => x.CreatorName == dto.CreatorName!)
                 .Where(x => !string.IsNullOrEmpty(x.Knowledge.Id))
                 .OrderByDescending(x => x.CreationTime)
                 .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);