qinchaoyue 3 месяцев назад
Родитель
Сommit
bf8502b8b5

+ 3 - 2
src/Hotline.Api/Controllers/ExportData/ExportDataController.cs

@@ -1,4 +1,5 @@
 using Hotline.Application.ExportExcel;
+using Hotline.Share.Attributes;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Tools;
 using Microsoft.AspNetCore.Mvc;
@@ -96,7 +97,7 @@ public class ExportDataController : BaseController
         var result = method.Invoke(serviceInstance, [queryDto]);
 
         var returnType = method.ReturnType.GetGenericArguments()[0];
-        var description = method.GetCustomAttribute<DescriptionAttribute>()?.Description + "_";
+        var fileName = method.GetFileName() + "_";
         if (pageIndex == null || pageSize == null)
         {
             isExportAll = true;
@@ -104,7 +105,7 @@ public class ExportDataController : BaseController
             pageSize = 20;
         }
 
-        return _exportApplication.GetExcelFile(returnType, genericType, exportData, ConvertToList(result, (bool)isExportAll, (int)pageIndex, (int)pageSize), description);
+        return _exportApplication.GetExcelFile(returnType, genericType, exportData, ConvertToList(result, (bool)isExportAll, (int)pageIndex, (int)pageSize), fileName);
     }
 
     public static List<object>? ConvertToList(object? result, bool isExportAll, int pageIndex, int pageSize)

+ 7 - 6
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -3,6 +3,7 @@ using Hotline.Caching.Interfaces;
 using Hotline.File;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Settings;
+using Hotline.Share.Attributes;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
@@ -72,7 +73,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         return id;
     }
 
-    [Description("行业集合")]
+    [ExportExcel("行业集合")]
     public ISugarQueryable<IndustryItemsOutDto> GetIndustres(IndustryListInDto dto)
     {
         var query = _industryRepository.Queryable()
@@ -124,7 +125,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     }
 
     #region 行业线索
-    [Description("行业线索")]
+    [ExportExcel("行业线索")]
     public ISugarQueryable<IndustryCaseItemOutDto> GetIndustryCaseItems(IndustryCaseItemInDto dto)
     {
         var query = _industryCaseRepository.Queryable()
@@ -182,7 +183,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("行业审批短信")]
+    [ExportExcel("行业审批短信")]
     public ISugarQueryable<SnapshotSMSTemplateItemsOutDto> GetSMSTemplates(SnapshotSMSTemplateItemsInDto dto)
     {
         var query = _snapshotSMSTemplateRepository.Queryable()
@@ -245,7 +246,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     /// <param name="dto"></param>
     /// <returns></returns>
     /// <exception cref="NotImplementedException"></exception>
-    [Description("区域从业人员")]
+    [ExportExcel("区域从业人员")]
     public ISugarQueryable<PractitionerItemsOutDto> GetPractitionerItems(PractitionerItemsInDto dto)
     {
         var query = _practitionerRepository.Queryable()
@@ -316,7 +317,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("志愿者名单")]
+    [ExportExcel("志愿者名单")]
     public ISugarQueryable<VolunteerItemsOutDto> GetVolunteerItems(VolunteerItemsInDto dto)
     {
         var query = _volunteerRepository.Queryable()
@@ -380,7 +381,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("志愿者上报")]
+    [ExportExcel("志愿者上报")]
     public ISugarQueryable<VolunteerReportItemsOutDto> GetVolunteerReportItems(VolunteerReportItemsInDto dto)
     {
         var query = _volunteerReportRepository.Queryable()

+ 7 - 6
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -1,4 +1,5 @@
 using Hotline.Orders;
+using Hotline.Share.Attributes;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.Order;
@@ -207,7 +208,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("市民红包审批")]
+    [ExportExcel("市民红包审批")]
     public ISugarQueryable<SnapshotOrderAuditItemsOutDto> GetRedPackAuditItems(SnapshotOrderAuditItemsInDto dto)
     {
         ERedPackAuditStatus? status = null;
@@ -285,7 +286,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("网格员红包审批")]
+    [ExportExcel("网格员红包审批")]
     public ISugarQueryable<SnapshotOrderGuiderAuditItemsOutDto> GetRedPackGuiderAuditItems(SnapshotOrderGuiderAuditItemsInDto dto)
     {
         var areaCode = _sessionContext.OrgAreaCode;
@@ -434,7 +435,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("市民红包发放记录")]
+    [ExportExcel("市民红包发放记录")]
     public ISugarQueryable<SnapshotRedPackRecordItemsOutDto> GetRedPackRecordItems(SnapshotRedPackRecordItemsInDto dto)
     {
         var query = _redPackRecordRepository.Queryable()
@@ -471,7 +472,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         return order;
     }
 
-    [Description("网格员红包发放记录")]
+    [ExportExcel("网格员红包发放记录")]
     public ISugarQueryable<SnapshotRedPackRecordItemsGuiderOutDto> GetRedPackRecordGuiderItems(SnapshotRedPackRecordItemsGuiderInDto dto)
     {
         var query = _redPackRecordRepository.Queryable()
@@ -492,7 +493,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         return query;
     }
 
-    [Description("红包发放明细")]
+    [ExportExcel("红包发放明细")]
     public ISugarQueryable<SnapshotRedPackRecordSendOutDto> GetRedPackRecordDetail(SnapshotRedPackRecordSendInDto dto)
     {
         var query = _redPackRecordRepository.Queryable()
@@ -524,7 +525,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("补充发放")]
+    [ExportExcel("补充发放")]
     public ISugarQueryable<SnapshotRedPackRecordSupplementItemsOutDto> GetRedPackRecordSupplementItems(SnapshotRedPackRecordSupplementItemsInDto dto)
     {
         var query = _supplementRecordRepository.Queryable()

+ 4 - 2
src/Hotline.Application/Snapshot/SnapshotOrderApplication.cs

@@ -3,6 +3,7 @@ using Hotline.File;
 using Hotline.FlowEngine.Notifications;
 using Hotline.FlowEngine.Workflows;
 using Hotline.Orders;
+using Hotline.Share.Attributes;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.File;
 using Hotline.Share.Dtos.FlowEngine;
@@ -170,7 +171,7 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("随手拍公开")]
+    [ExportExcel("随手拍公开")]
     public ISugarQueryable<GetOrderSnapshotPublishItemsOutDto> GetOrderSnapshotPublishItems(GetOrderSnapshotPublishItemsInDto dto)
     {
         var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
@@ -202,7 +203,7 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    [Description("工单标注")]
+    [ExportExcel("工单标注")]
     public ISugarQueryable<SignOrderSnapshotItemsOutDto> GetSignOrderSnapshotItems(SignOrderSnapshotItemsInDto dto)
     {
         var query = _orderSnapshotRepository.Queryable()
@@ -427,6 +428,7 @@ public class SnapshotOrderApplication : IOrderSnapshotApplication, IScopeDepende
 
     }
 
+    [ExportExcel("随手拍工单")]
     public ISugarQueryable<OrderSnapshotItemsOutDto> GetOrderSnapshotItems(OrderSnapshotItemsInDto dto)
     {
         var query = _orderSnapshotRepository.Queryable()

+ 19 - 0
src/Hotline.Share/Attributes/ExportExcelAttribute.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Attributes;
+public class ExportExcelAttribute : Attribute
+{
+    /// <summary>
+    /// 文件名称
+    /// </summary>
+    public string FileName { get; }
+
+    public ExportExcelAttribute(string fileName)
+    {
+        FileName = fileName;
+    }
+}

+ 20 - 0
src/Hotline.Share/Tools/MethodInfoExtensions.cs

@@ -0,0 +1,20 @@
+using Hotline.Share.Attributes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Tools;
+public static class MethodInfoExtensions
+{
+
+    public static string GetFileName(this MethodInfo? value)
+    {
+        if (value == null) return string.Empty;
+        var att = value.GetCustomAttribute<ExportExcelAttribute>();
+        if (att == null) return string.Empty;
+        return att.FileName;
+    }
+}