소스 검색

增加行业修改记录日志

qinchaoyue 4 달 전
부모
커밋
8f0090c85f

+ 12 - 0
src/Hotline.Api/Controllers/Snapshot/IndustryController.cs

@@ -5,6 +5,7 @@ using Hotline.Configurations;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Settings;
 using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Settings;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
 using Hotline.Snapshot;
@@ -291,4 +292,15 @@ public class IndustryController : BaseController
     public async Task<PagedDto<VolunteerReportItemsOutDto>> GetVolunteerReportItemsAsync([FromQuery]VolunteerReportItemsInDto dto)
         => (await _industryApplication.GetVolunteerReportItemsAsync(dto).ToPagedListAsync(dto)).ToPaged();
     #endregion
+
+    #region 修改行业记录
+    /// <summary>
+    /// 行业修改记录
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("order/industry/log")]
+    public async Task<PagedDto<IndustryLogItemsOutDto>> GetIndustryLogItemsAsync([FromQuery] IndustryLogItemsInDto dto)
+        => (await _industryApplication.GetIndustryLogItemsAsync(dto).ToPagedListAsync(dto)).ToPaged();
+    #endregion
 }

+ 7 - 0
src/Hotline.Application/Snapshot/IIndustryApplication.cs

@@ -170,4 +170,11 @@ public interface IIndustryApplication
     /// <param name="dto"></param>
     /// <returns></returns>
     ISugarQueryable<VolunteerReportItemsOutDto> GetVolunteerReportItemsAsync(VolunteerReportItemsInDto dto);
+
+    /// <summary>
+    /// 行业修改记录
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    ISugarQueryable<IndustryLogItemsOutDto> GetIndustryLogItemsAsync(IndustryLogItemsInDto dto);
 }

+ 21 - 1
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -30,8 +30,9 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
     private readonly IPractitionerRepository _practitionerRepository;
     private readonly IVolunteerRepository _volunteerRepository;
     private readonly IVolunteerReportRepository _volunteerReportRepository;
+    private readonly IIndustryLogRepository _industryLogRepository;
 
-    public IndustryApplication(IIndustryRepository industryRepository, IFileRepository fileRepository, ISystemSettingCacheManager sysSetting, IIndustryCaseRepository industryCaseRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IPractitionerRepository practitionerRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository)
+    public IndustryApplication(IIndustryRepository industryRepository, IFileRepository fileRepository, ISystemSettingCacheManager sysSetting, IIndustryCaseRepository industryCaseRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IPractitionerRepository practitionerRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, IIndustryLogRepository industryLogRepository)
     {
         _industryRepository = industryRepository;
         _fileRepository = fileRepository;
@@ -41,6 +42,7 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         _practitionerRepository = practitionerRepository;
         _volunteerRepository = volunteerRepository;
         _volunteerReportRepository = volunteerReportRepository;
+        _industryLogRepository = industryLogRepository;
     }
     /// <summary>
     /// 新增行业
@@ -374,5 +376,23 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
             .Select<VolunteerReportItemsOutDto>();
         return query;
     }
+
+    /// <summary>
+    /// 行业修改记录
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    public ISugarQueryable<IndustryLogItemsOutDto> GetIndustryLogItemsAsync(IndustryLogItemsInDto dto)
+    {
+        var query = _industryLogRepository.Queryable()
+            .WhereIF(dto.No.NotNullOrEmpty(), m => m.No.Contains(dto.No))
+            .WhereIF(dto.ChangeName.NotNullOrEmpty(), m => m.CreatorName.Contains(dto.ChangeName))
+            .WhereIF(dto.IndustryName.NotNullOrEmpty(), m => m.IndustryName.Contains(dto.IndustryName))
+            .WhereIF(dto.oldIndustryName.NotNullOrEmpty(), m => m.OldIndustryName.Contains(dto.oldIndustryName))
+            .WhereIF(dto.BeginTime.HasValue && dto.EndTime.HasValue, m => m.CreationTime >= dto.BeginTime.Value && m.CreationTime <= dto.EndTime.Value)
+            .Select<IndustryLogItemsOutDto>();
+        return query;
+    }
+
     #endregion
 }

+ 51 - 0
src/Hotline.Share/Dtos/Snapshot/IndustryDto.cs

@@ -521,3 +521,54 @@ public class PractitionerItemsOutDto
     /// </summary>
     public string GenderTxt => Gender.GetDescription();
 }
+
+/// <summary>
+/// 修改行业记录入参
+/// </summary>
+/// <param name="No">编号</param>
+/// <param name="ChangeName">修改人</param>
+/// <param name="oldIndustryName">旧行业名称</param>
+/// <param name="IndustryName">新行业名称</param>
+/// <param name="BeginTime">开始时间</param>
+/// <param name="EndTime">结束时间</param>
+public record IndustryLogItemsInDto(string? No, string? ChangeName, string? oldIndustryName, string? IndustryName
+    , DateTime? BeginTime, DateTime? EndTime) : PagedRequest;
+
+
+public class IndustryLogItemsOutDto
+{
+    /// <summary>
+    /// OrderId
+    /// </summary>
+    public string OrderId { get; set; }
+
+    /// <summary>
+    /// 行业名称
+    /// </summary>
+    public string OldIndustryName { get; set; }
+
+    /// <summary>
+    /// 行业名称
+    /// </summary>
+    public string IndustryName { get; set; }
+
+    /// <summary>
+    /// 编号
+    /// </summary>
+    public string No { get; set; }
+
+    /// <summary>
+    /// 标题
+    /// </summary>
+    public string Title { get; set; }
+
+    /// <summary>
+    /// 时间
+    /// </summary>
+    public DateTime CreationTime { get; set; }
+
+    /// <summary>
+    /// 修改人
+    /// </summary>
+    public string CreatorName { get; set; }
+}

+ 11 - 1
src/Hotline/Orders/DatabaseEventHandler/OrderSnapshotEventHandler.cs

@@ -13,11 +13,13 @@ public class OrderSnapshotEventHandler : IUpdateDatabaseEvent<OrderSnapshot>, IS
 {
     private readonly IIndustryLogRepository _industryLogRepository;
     private readonly IOrderSnapshotRepository _orderSnapshotRepository;
+    private readonly IOrderRepository _orderRepository;
 
-    public OrderSnapshotEventHandler(IIndustryLogRepository industryLogRepository, IOrderSnapshotRepository orderSnapshotRepository)
+    public OrderSnapshotEventHandler(IIndustryLogRepository industryLogRepository, IOrderSnapshotRepository orderSnapshotRepository, IOrderRepository orderRepository)
     {
         _industryLogRepository = industryLogRepository;
         _orderSnapshotRepository = orderSnapshotRepository;
+        _orderRepository = orderRepository;
     }
 
     public void OnInserted(OrderSnapshot entity)
@@ -39,12 +41,20 @@ public class OrderSnapshotEventHandler : IUpdateDatabaseEvent<OrderSnapshot>, IS
                 .Select(m => m.IndustryName)
                 .First();
             if (industryName == industry) return;
+
+            var order = _orderRepository.Queryable()
+                .Where(m => m.Id == entity.Id)
+                .Select(m => new { m.No, m.Title })
+                .First();
+            if (order is null) return;
             var entityLog = new IndustryLog
             {
                 IndustryName = propertyValue.ToString(),
                 OldIndustryName = industry,
                 CreationTime = DateTime.Now,
                 OrderId = entity.Id,
+                Title = order.Title,
+                No = order.No
             };
             _industryLogRepository.AddAsync(entityLog).GetAwaiter().GetResult();
         }

+ 10 - 0
src/Hotline/Snapshot/IndustryLog.cs

@@ -19,4 +19,14 @@ public class IndustryLog : FullStateEntity
     /// 行业名称
     /// </summary>
     public string IndustryName { get; set; }
+
+    /// <summary>
+    /// 编号
+    /// </summary>
+    public string No { get; set; }
+
+    /// <summary>
+    /// 标题
+    /// </summary>
+    public string Title { get; set; }
 }