瀏覽代碼

新增行业集合接口

qinchaoyue 4 月之前
父節點
當前提交
f3a28a26eb

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

@@ -1,5 +1,8 @@
 using Hotline.Application.Snapshot;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Tools;
 using Hotline.Snapshot.Interfaces;
 using Microsoft.AspNetCore.Mvc;
 
@@ -26,4 +29,12 @@ public class IndustryController : BaseController
     [HttpPost]
     public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
         => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
+
+    /// <summary>
+    /// 获取行业集合
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet("industry")]
+    public async Task<PagedDto<IndustryOutDto>> GetIndustryAsync([FromQuery] IndustryListInDto dto)
+        => (await _industryApplication.GetIndustres(dto).ToPagedListAsync(dto, HttpContext.RequestAborted)).ToPaged();
 }

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

@@ -1,4 +1,5 @@
 using Hotline.Share.Dtos.Snapshot;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,4 +14,11 @@ public interface IIndustryApplication
     /// </summary>
     /// <returns></returns>
     Task<string> AddIndustryAsync(AddIndustryDto dto, CancellationToken cancellationToken);
+
+    /// <summary>
+    /// 获取行业集合
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    ISugarQueryable<IndustryOutDto> GetIndustres(IndustryListInDto dto);
 }

+ 14 - 0
src/Hotline.Application/Snapshot/IndustryApplication.cs

@@ -1,9 +1,12 @@
 using Hotline.File;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Mapster;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -41,4 +44,15 @@ public class IndustryApplication : IIndustryApplication, IScopeDependency
         }
         return id;
     }
+
+    public ISugarQueryable<IndustryOutDto> GetIndustres(IndustryListInDto dto)
+    {
+        var query = _industryRepository.Queryable()
+            .WhereIF(dto.Name.NotNullOrEmpty(), m => m.Name.Contains(dto.Name))
+            .WhereIF(dto.ApproveOrgName.NotNullOrEmpty(), m => m.ApproveOrgName.Contains(dto.ApproveOrgName))
+            .Select<IndustryOutDto>();
+        
+
+        return query;
+    }
 }

+ 41 - 0
src/Hotline.Share/Dtos/Snapshot/HomePageDto.cs

@@ -1,5 +1,6 @@
 using Hotline.Share.Dtos.Settings;
 using Hotline.Share.Enums.Snapshot;
+using Hotline.Share.Requests;
 using XF.Utility.EnumExtensions;
 
 namespace Hotline.Share.Dtos.Snapshot;
@@ -93,6 +94,39 @@ public class HomeIndustryOutDto
     public string IndustryTypeTxt => IndustryType.GetDescription();
 }
 
+public class IndustryItemsOutDto : IndustryOutDto
+{
+    /// <summary>
+    /// 审批部门Id
+    /// </summary>
+    public string? ApproveOrgId { get; set; }
+
+    /// <summary>
+    /// 审批部门名字
+    /// </summary>
+    public string? ApproveOrgName { get; set; }
+
+    /// <summary>
+    /// 市民发放红包金额(单位:分)
+    /// </summary>
+    public int CitizenReadPackAmount { get; set; }
+
+    /// <summary>
+    /// 网络员发放红包金额(单位:分)
+    /// </summary>
+    public int GuiderReadPackAmount { get; set; }
+
+    /// <summary>
+    /// 是否启用
+    /// </summary>
+    public bool IsEnable { get; set; }
+
+    /// <summary>
+    /// 排序
+    /// </summary>
+    public int DisplayOrder { get; set; }
+
+}
 public class IndustryOutDto
 { 
     /// <summary>
@@ -131,6 +165,13 @@ public class IndustryOutDto
     public string? PageCareUrl { get; set; }
 }
 
+/// <summary>
+/// 行业集合入参
+/// </summary>
+/// <param name="name">名称</param>
+/// <param name="departmentName">审批部门</param>
+public record IndustryListInDto(string? Name, string? ApproveOrgName) : PagedRequest;
+
 public class IndustryBaseOutDto
 {
     /// <summary>