Преглед на файлове

自贡12345 - 预案库管理

libin преди 4 месеца
родител
ревизия
f71c2ce7ba

+ 50 - 0
src/Hotline.Api/Controllers/PlanController.cs

@@ -12,6 +12,9 @@ using Hotline.Share.Tools;
 using Hotline.Share.Enums.Planlibrary;
 using Hotline.Application.ExportWord;
 using Hotline.Application.Tools;
+using Hotline.KnowledgeBase;
+using Hotline.Share.Dtos.Knowledge;
+using System.Data;
 
 namespace Hotline.Api.Controllers
 {
@@ -129,6 +132,30 @@ namespace Hotline.Api.Controllers
 
         #region 预案库管理
 
+        /// <summary>
+        /// 预案库分类列表
+        /// </summary>
+        /// <param name="IsEnable"></param>
+        /// <returns></returns>
+        [HttpGet("list/treelist")]
+        public async Task<List<PlanTypeDto>> QueryAllPlanTypeTreeList(bool? IsEnable)
+        {
+            return await _planTypeRepository.Queryable()
+                .WhereIF(IsEnable.HasValue, x => x.IsEnable == IsEnable)
+                .Where(x => SqlFunc.Subqueryable<PlanTypeOrg>().Where(to => to.TypeId == x.Id).Any() ||
+                SqlFunc.Subqueryable<PlanTypeOrg>().Where(to => to.TypeId == x.Id).NotAny()
+                )
+                .Select(x => new PlanTypeDto()
+                {
+                    Id = x.Id.SelectAll(),
+                    PlanNum = SqlFunc.Subqueryable<PlanRelationType>().LeftJoin<PlanList>((kr, k) => kr.PlanId == k.Id)
+                         .Where((kr, k) => kr.PlanTypeSpliceName.StartsWith(x.SpliceName))
+                         .DistinctCount(kr => kr.PlanId)
+                }
+                )
+                .OrderBy(x => x.Sort).ToTreeAsync(it => it.children, it => it.ParentId, null, it => it.Id);
+        }
+
         /// <summary>
         /// 预案库列表
         /// </summary>
@@ -348,5 +375,28 @@ namespace Hotline.Api.Controllers
 
         #endregion
 
+        #region 预案库检索
+
+        /// <summary>
+        /// 预案库列表前10
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("list/top10")]
+        public async Task<List<PlanPageViewDto>> QueryTop10PlanList()
+        {
+            return await _planListRepository.Queryable()
+                .Take(10)
+                .Where(x => x.Status == EPlanStatus.OnShelf)
+                .Select(x => new PlanPageViewDto
+                {
+                    Id = x.Id,
+                    Title = x.Title,
+                    PageView = x.PageView
+                })
+                .OrderBy(x => x.PageView, OrderByType.Desc)
+                .ToListAsync();
+        }
+
+        #endregion
     }
 }

+ 5 - 1
src/Hotline.Application/Planlibrary/PlanApplication.cs

@@ -238,7 +238,11 @@ namespace Hotline.Application.Planlibrary
                 .WhereIF(pagedDto.ExaminTimeStart.HasValue, x => x.ExaminTime >= pagedDto.ExaminTimeStart)
                 .WhereIF(pagedDto.ExaminTimeEnd.HasValue, x => x.ExaminTime <= pagedDto.ExaminTimeEnd)
 
-                .OrderByDescending(d => d.CreationTime)
+                .OrderByIF(string.IsNullOrEmpty(pagedDto.SortField), d => d.CreationTime, OrderByType.Desc)
+                .OrderByIF(pagedDto is { SortField: "PageView" }, d => d.PageView, OrderByType.Desc)         //阅读量
+                .OrderByIF(pagedDto is { SortField: "Score" }, d => d.Score, OrderByType.Desc)               //评分
+                .OrderByIF(pagedDto is { SortField: "CreationTime" }, d => d.CreationTime, OrderByType.Desc) //创建时间
+
                 .ToPagedListAsync(pagedDto.PageIndex, pagedDto.PageSize, cancellationToken);
 
             return (total, _mapper.Map<IList<PlanDataDto>>(temp));

+ 8 - 0
src/Hotline.Share/Dtos/Planlibrary/PlanDataDto.cs

@@ -178,4 +178,12 @@ public class PlanInfoExportDto
     /// 导出格式
     /// </summary>
     public EFileType FileType { get; set; }
+}
+
+
+public class PlanPageViewDto
+{
+    public string Id { get; set; }
+    public string Title { get; set; }
+    public int PageView { get; set; }
 }

+ 10 - 0
src/Hotline.Share/Dtos/Planlibrary/PlanListDto.cs

@@ -140,6 +140,16 @@ namespace Hotline.Share.Dtos.Planlibrary
         /// 评分
         /// </summary>
         public decimal? Score { get; set; } = decimal.Zero;
+
+        /// <summary>
+        /// 排序(需要被排序的字段名)
+        /// </summary>
+        public string? SortField { get; set; }
+
+        /// <summary>
+        /// 排序方向 (0: 升序Asc; 1: 降序Desc)
+        /// </summary>
+        public int OrderByType { get; set; } = 1;
     }