Explorar o código

修复随手拍公告导出

qinchaoyue hai 3 meses
pai
achega
2bd6da80c3

+ 2 - 14
src/Hotline.Api/Controllers/Snapshot/SnapshotBulletinController.cs

@@ -43,20 +43,8 @@ public class SnapshotBulletinController : BaseController
     /// <param name="dto"></param>
     /// <returns></returns>
     [HttpGet("bulletin/query")]
-    public async Task<PagedDto<SnapshotBulletinItemsOutDto>> QueryBulletinList([FromQuery] SnapshotBulletinItemsInDto dto)
-    {
-        var query = _bulletinRepository.Queryable()
-            .Includes(x => x.ExaminMan)
-            .WhereIF(!string.IsNullOrEmpty(dto.SnapshotBulletinTypeName), d => d.SnapshotBulletinTypeName.Contains(dto.SnapshotBulletinTypeName))
-            .WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Title.Contains(dto.Title))
-            .WhereIF(dto.BeginCreationTime.HasValue, d => d.BulletinTime >= dto.BeginCreationTime)
-            .WhereIF(dto.EndCreationTime.HasValue, d => d.BulletinTime <= dto.EndCreationTime)
-            .WhereIF(dto.State.HasValue, d => d.BulletinState == dto.State)
-            .OrderByDescending(d => d.CreationTime)
-            .Select<SnapshotBulletinItemsOutDto>();
-        return (await query
-            .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted)).ToPaged();
-    }
+    public async Task<PagedDto<SnapshotBulletinItemsOutDto>> QueryBulletinItems([FromQuery] SnapshotBulletinItemsInDto dto)
+        => (await _bulletinApplication.QueryBulletinItems(dto).ToPagedListAsync(dto)).ToPaged();
 
     /// <summary>
     /// 公告详情(内部)

+ 4 - 1
src/Hotline.Application/Snapshot/ISnapshotBulletinApplication.cs

@@ -1,4 +1,6 @@
-using System;
+using Hotline.Share.Dtos.Snapshot;
+using SqlSugar;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -14,4 +16,5 @@ public interface ISnapshotBulletinApplication
     /// <param name="sHtmlText"></param>
     /// <returns></returns>
     string GetSiteUrls(string sHtmlText);
+    ISugarQueryable<SnapshotBulletinItemsOutDto> QueryBulletinItems(SnapshotBulletinItemsInDto dto);
 }

+ 23 - 1
src/Hotline.Application/Snapshot/SnapshotBulletinApplication.cs

@@ -1,5 +1,10 @@
 using Hotline.Caching.Interfaces;
 using Hotline.Settings;
+using Hotline.Share.Attributes;
+using Hotline.Share.Dtos.Snapshot;
+using Hotline.Snapshot.Interfaces;
+using Microsoft.AspNetCore.Http;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,10 +18,12 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
 {
 
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+    private readonly ISnapshotBulletinRepository _bulletinRepository;
 
-    public SnapshotBulletinApplication(ISystemSettingCacheManager systemSettingCacheManager)
+    public SnapshotBulletinApplication(ISystemSettingCacheManager systemSettingCacheManager, ISnapshotBulletinRepository bulletinRepository)
     {
         _systemSettingCacheManager = systemSettingCacheManager;
+        _bulletinRepository = bulletinRepository;
     }
 
     /// <summary>
@@ -65,4 +72,19 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
 
         return sb.ToString();
     }
+
+    [ExportExcel("随手拍公告")]
+    public ISugarQueryable<SnapshotBulletinItemsOutDto> QueryBulletinItems(SnapshotBulletinItemsInDto dto)
+    {
+        var query = _bulletinRepository.Queryable()
+            .Includes(x => x.ExaminMan)
+            .WhereIF(!string.IsNullOrEmpty(dto.SnapshotBulletinTypeName), d => d.SnapshotBulletinTypeName.Contains(dto.SnapshotBulletinTypeName))
+            .WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Title.Contains(dto.Title))
+            .WhereIF(dto.BeginCreationTime.HasValue, d => d.BulletinTime >= dto.BeginCreationTime)
+            .WhereIF(dto.EndCreationTime.HasValue, d => d.BulletinTime <= dto.EndCreationTime)
+            .WhereIF(dto.State.HasValue, d => d.BulletinState == dto.State)
+            .OrderByDescending(d => d.CreationTime)
+            .Select<SnapshotBulletinItemsOutDto>();
+        return query;
+    }
 }