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

Merge branch 'feature/snapshot' into dev

qinchaoyue преди 4 месеца
родител
ревизия
0bf7c12b35

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

@@ -30,6 +30,15 @@ public class IndustryController : BaseController
     public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
         => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
 
+    /// <summary>
+    /// 行业详情
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    [HttpGet("{id}")]
+    public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
+        => await _industryApplication.GetIndustryDetailAsync(id);
+
     /// <summary>
     /// 获取行业集合
     /// </summary>

+ 2 - 2
src/Hotline.Application.Tests/Startup.cs

@@ -154,8 +154,8 @@ public class Startup
                 .ToList()
                 .ForEach(d => ServiceRegister.Register(services, d));
 
-            services.AddScoped<IThirdIdentiyService, WeChatService>();
-            //services.AddScoped<IThirdIdentiyService, ThirdTestService>();
+            //services.AddScoped<IThirdIdentiyService, WeChatService>();
+            services.AddScoped<IThirdIdentiyService, ThirdTestService>();
 
             //services.AddScoped<IThirdAccountRepository, ThirdAccountRepository>();
             services.AddApplication();

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

@@ -21,4 +21,11 @@ public interface IIndustryApplication
     /// <param name="dto"></param>
     /// <returns></returns>
     ISugarQueryable<IndustryItemsOutDto> GetIndustres(IndustryListInDto dto);
+
+    /// <summary>
+    /// 获取行业详情
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id);
 }

+ 24 - 2
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -1,4 +1,5 @@
-using Hotline.File;
+using Hotline.Caching.Interfaces;
+using Hotline.File;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
@@ -19,11 +20,13 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
 {
     private readonly IIndustryRepository _industryRepository;
     private readonly IFileRepository _fileRepository;
+    private readonly ISystemSettingCacheManager _sysSetting;
 
-    public IndustryApplication(IIndustryRepository industryRepository, IFileRepository fileRepository)
+    public IndustryApplication(IIndustryRepository industryRepository, IFileRepository fileRepository, ISystemSettingCacheManager sysSetting)
     {
         _industryRepository = industryRepository;
         _fileRepository = fileRepository;
+        _sysSetting = sysSetting;
     }
 
     /// <summary>
@@ -55,4 +58,23 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
 
         return query;
     }
+
+    public async Task<IndustryDetailOutDto> GetIndustryDetailAsync(string id)
+    {
+        var fileServiceUrl = _sysSetting.FileServerUrl;
+        var fileDownloadApi = fileServiceUrl + _sysSetting.FileDownloadApi;
+        var industry = await _industryRepository.GetAsync(id);
+        var files = await _fileRepository.GetByKeyAsync(id, CancellationToken.None);
+        var outDto = industry.Adapt<IndustryDetailOutDto>();
+        outDto.Files = files.Adapt<IList<IndustryFileDto>>();
+        if (outDto.BackgroundImgUrl.NotNullOrEmpty())
+            outDto.BackgroundImgUrl = fileDownloadApi + outDto.BackgroundImgUrl;
+        if (outDto.BannerImgUrl.NotNullOrEmpty())
+            outDto.BannerImgUrl = fileDownloadApi + outDto.BannerImgUrl;
+        if (outDto.CareCellImgUrl.NotNullOrEmpty())
+            outDto.CareCellImgUrl = fileDownloadApi + outDto.CareCellImgUrl;
+        if (outDto.CellImgUrl.NotNullOrEmpty())
+            outDto.CellImgUrl = fileDownloadApi + outDto.CellImgUrl;
+        return outDto;
+    }
 }

+ 3 - 3
src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs

@@ -234,10 +234,10 @@ public abstract class SnapshotApplicationBase
     /// <returns></returns>
     public async Task<OrderPublishDetailOutDto> GetOrderPublishDetailAsync(string id, CancellationToken requestAborted)
     {
-        var publish = await _snapshotOrderPublishRepository.GetAsync(id) ??
+        var order = await _orderRepository.GetAsync(id) ??
             throw UserFriendlyException.SameMessage("工单不存在");
 
-        var outDto = publish.Adapt<OrderPublishDetailOutDto>();
+        var outDto = order.Adapt<OrderPublishDetailOutDto>();
         var fileServiceUrl = _sysSetting.FileServerUrl;
         if (outDto.FileJson != null)
         {
@@ -247,7 +247,7 @@ public abstract class SnapshotApplicationBase
             }
         }
         var traces = await _workflowTraceRepository.Queryable()
-            .Where(m => m.ExternalId == publish.OrderId && m.Status == EWorkflowStepStatus.Handled)
+            .Where(m => m.ExternalId == order.Id && m.Status == EWorkflowStepStatus.Handled)
             .OrderBy(m => m.AcceptTime)
             .ToListAsync(requestAborted);
         var centre = traces.Where(m => m.StepType == EStepType.End || m.StepType == EStepType.Start || m.BusinessType == EBusinessType.Send || m.BusinessType == EBusinessType.Seat || m.BusinessType == EBusinessType.File)

+ 31 - 2
src/Hotline.Share/Dtos/Snapshot/IndustryDto.cs

@@ -1,4 +1,5 @@
-using Hotline.Share.Dtos.Settings;
+using Hotline.Share.Dtos.File;
+using Hotline.Share.Dtos.Settings;
 using Hotline.Share.Requests;
 using System;
 using System.Collections.Generic;
@@ -12,6 +13,34 @@ internal class IndustryDto
 {
 }
 
+public class IndustryDetailOutDto : IndustryItemsOutDto
+{
+    /// <summary>
+    /// 背景图片 url
+    /// </summary>
+    public string? BackgroundImgUrl { get; set; }
+
+    /// <summary>
+    /// Banner 图片 url
+    /// </summary>
+    public string? BannerImgUrl { get; set; }
+
+    /// <summary>
+    /// 宫格图
+    /// </summary>
+    public string? CellImgUrl { get; set; }
+
+    /// <summary>
+    /// 关怀宫格图
+    /// </summary>
+    public string? CareCellImgUrl { get; set; }
+
+    /// <summary>
+    /// 附件集合(小程序上面可以下载的 doc 文件)
+    /// </summary>
+    public IList<IndustryFileDto> Files { get; set; }
+}
+
 public class IndustryItemsOutDto : IndustryOutDto
 {
     /// <summary>
@@ -43,8 +72,8 @@ public class IndustryItemsOutDto : IndustryOutDto
     /// 排序
     /// </summary>
     public int DisplayOrder { get; set; }
-
 }
+
 public class IndustryOutDto
 {
     /// <summary>