qinchaoyue 4 月之前
父节点
当前提交
0c0f0bba47

+ 1 - 1
src/Hotline.Api/Controllers/Snapshot/IndustryController.cs

@@ -25,5 +25,5 @@ public class IndustryController : BaseController
     /// <returns></returns>
     [HttpPost]
     public async Task<string> AddIndustry([FromBody] AddIndustryDto dto)
-        => _industryApplication.AddIndustry(dto);
+        => await _industryApplication.AddIndustryAsync(dto, HttpContext.RequestAborted);
 }

+ 18 - 0
src/Hotline.Application.Contracts/Validators/Snapshot/IndustryValidator.cs

@@ -0,0 +1,18 @@
+using FluentValidation;
+using Hotline.Share.Dtos.Snapshot;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Application.Contracts.Validators.Snapshot;
+public class IndustryValidator : AbstractValidator<AddIndustryDto>
+{
+    public IndustryValidator()
+    {
+        RuleFor(m => m.Name).NotEmpty().WithMessage("行业名称不能为空");
+        RuleFor(m => m.CitizenReadPackAmount).NotEqual(0).WithMessage("市民红包不能为空");
+        RuleFor(m => m.GuiderReadPackAmount).NotEqual(0).WithMessage("网格员红包不能为空");
+    }
+}

+ 17 - 0
src/Hotline.Application/Mappers/SnapshotMapperConfigs.cs

@@ -0,0 +1,17 @@
+using Hotline.Share.Dtos.Snapshot;
+using Hotline.Snapshot;
+using Mapster;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Application.Mappers;
+public class SnapshotMapperConfigs : IRegister
+{
+    public void Register(TypeAdapterConfig config)
+    {
+        config.ForType<AddIndustryDto, Industry>();
+    }
+}

+ 1 - 1
src/Hotline.Application/Snapshot/IIndustryApplication.cs

@@ -12,5 +12,5 @@ public interface IIndustryApplication
     /// 新增行业
     /// </summary>
     /// <returns></returns>
-    string AddIndustry(AddIndustryDto dto);
+    Task<string> AddIndustryAsync(AddIndustryDto dto, CancellationToken cancellationToken);
 }

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

@@ -1,4 +1,6 @@
 using Hotline.Share.Dtos.Snapshot;
+using Hotline.Snapshot;
+using Mapster;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -9,8 +11,23 @@ using XF.Domain.Dependency;
 namespace Hotline.Application.Snapshot;
 public class IndustryApplication : IIndustryApplication, IScopeDependency
 {
-    public string AddIndustry(AddIndustryDto dto)
+    private readonly IIndustryRepository _industryRepository;
+
+    public IndustryApplication(IIndustryRepository industryRepository)
+    {
+        _industryRepository = industryRepository;
+    }
+
+    /// <summary>
+    /// 新增行业
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    /// <exception cref="NotImplementedException"></exception>
+    public async Task<string> AddIndustryAsync(AddIndustryDto dto, CancellationToken cancellationToken)
     {
-        throw new NotImplementedException();
+        var entity = dto.Adapt<Industry>();
+        var id = await _industryRepository.AddAsync(entity, cancellationToken);
+        return id;
     }
 }

+ 8 - 2
src/Hotline.Repository.SqlSugar/Snapshot/IndustryRepository.cs

@@ -1,4 +1,7 @@
-using Hotline.Snapshot;
+using Hotline.Orders;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Snapshot;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,6 +10,9 @@ using System.Threading.Tasks;
 using XF.Domain.Dependency;
 
 namespace Hotline.Repository.SqlSugar.Snapshot;
-public class IndustryRepository : IIndustryRepository, IScopeDependency
+public class IndustryRepository : BaseRepository<Industry>, IIndustryRepository, IScopeDependency
 {
+    public IndustryRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
+    {
+    }
 }

+ 127 - 1
src/Hotline.Share/Dtos/Snapshot/IndustryDto.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -10,6 +11,131 @@ internal class IndustryDto
 }
 
 public class AddIndustryDto
-{ 
+{
+    /// <summary>
+    /// 行业名称
+    /// </summary>
+    [Required]
+    public string Name { get; set; }
+
+    /// <summary>
+    /// 标题追加信息
+    /// </summary>
+    public string TitleSuffix { get; set; } = string.Empty;
+
+    /// <summary>
+    /// 审批部门Id
+    /// </summary>
+    public string? ApproveOrgId { get; set; }
+
+    /// <summary>
+    /// 审批部门名字
+    /// </summary>
+    public string? ApproveOrgName { get; set; }
+
+    /// <summary>
+    /// 受理类型
+    /// </summary>
+    public string AcceptType { get; set; } = string.Empty;
+
+    /// <summary>
+    /// 受理类型代码
+    /// </summary>
+    public string? AcceptTypeCode { get; set; }
+
+    /// <summary>
+    /// 市民发放红包金额(单位:元)
+    /// </summary>
+    [Required]
+    public int CitizenReadPackAmount { get; set; }
+
+    /// <summary>
+    /// 网络员发放红包金额(单位:元)
+    /// </summary>
+    [Required]
+    public int GuiderReadPackAmount { get; set; }
+
+    /// <summary>
+    /// 是否启用
+    /// </summary>
+    public bool IsEnable { get; set; }
+
+    /// <summary>
+    /// 帮助引导用语
+    /// </summary>
+    public string? TxtHelpRemarks { get; set; }
+
+    /// <summary>
+    /// 宫格说明文本
+    /// </summary>
+    public string TxtRemarks { get; set; } = string.Empty;
+
+    /// <summary>
+    /// 关怀说明
+    /// </summary>
+    public string TxtCareRemarks { get; set; }
+
+    /// <summary>
+    /// 排序
+    /// </summary>
+    public int DisplayOrder { get; set; } = 0;
+
+    /// <summary>
+    /// 阶段性回复间隔时间(小时)
+    /// </summary>
+    public int IntervalTime { get; set; } = 0;
+
+    /// <summary>
+    /// 页面Url
+    /// </summary>
+    public string PageUrl { get; set; }
+
+    /// <summary>
+    /// 关怀页面Url
+    /// </summary>
+    public string PageCareUrl { get; set; }
+
+    /// <summary>
+    /// 关联宣传学习
+    /// 从字典中取"公告类型"
+    /// </summary>
+    public string BulletinTypePublicityId { get; set; }
+
+    /// <summary>
+    /// 关联宣传学习
+    /// 从字典中取"公告类型"
+    /// </summary>
+    public string BulletinTypePublicityName { get; set; }
+
+    /// <summary>
+    /// 关联操作指引
+    /// 从字典中取"公告类型"
+    /// </summary>
+    public string BulletinTypeGuideId { get; set; }
+
+    /// <summary>
+    /// 关联操作指引
+    /// 从字典中取"公告类型"
+    /// </summary>
+    public string BulletinTypeGuideame { get; set; }
+
+    /// <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; }
 }

+ 4 - 2
src/Hotline/Snapshot/IIndustryRepository.cs

@@ -1,10 +1,12 @@
-using System;
+using Hotline.Settings;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using XF.Domain.Repository;
 
 namespace Hotline.Snapshot;
-public class IIndustryRepository
+public interface IIndustryRepository : IRepository<Industry>
 {
 }

+ 15 - 15
src/Hotline/Snapshot/Industry.cs

@@ -20,7 +20,7 @@ public class Industry : CreationSoftDeleteEntity
     /// 标题追加信息
     /// </summary>
     [SugarColumn(ColumnDescription ="标题追加信息")]
-    public string TitleSuffix { get; set; }
+    public string? TitleSuffix { get; set; }
 
     /// <summary>
     /// 审批部门Id
@@ -38,7 +38,7 @@ public class Industry : CreationSoftDeleteEntity
     /// 受理类型
     /// </summary>
     [SugarColumn(ColumnDescription ="受理类型")]
-    public string AcceptType { get; set; }
+    public string? AcceptType { get; set; }
 
     /// <summary>
     /// 受理类型代码
@@ -56,7 +56,7 @@ public class Industry : CreationSoftDeleteEntity
     /// 网络员发放红包金额(单位:分)
     /// </summary>
     [SugarColumn(ColumnDescription = "网络员发放红包金额(单位:分)")]
-    public int? GuiderReadPackAmount { get; set; }
+    public int GuiderReadPackAmount { get; set; }
 
     /// <summary>
     /// 是否启用
@@ -74,13 +74,13 @@ public class Industry : CreationSoftDeleteEntity
     /// 宫格说明文本
     /// </summary>
     [SugarColumn(ColumnDescription ="宫格说明文本")]
-    public string TxtRemarks { get; set; }
+    public string? TxtRemarks { get; set; }
 
     /// <summary>
     /// 关怀说明
     /// </summary>
     [SugarColumn(ColumnDescription ="关怀说明")]
-    public string TxtCareRemarks { get; set; }
+    public string? TxtCareRemarks { get; set; }
 
     /// <summary>
     /// 排序
@@ -98,63 +98,63 @@ public class Industry : CreationSoftDeleteEntity
     /// 页面Url
     /// </summary>
     [SugarColumn(ColumnDescription ="页面Url")]
-    public string PageUrl { get; set; }
+    public string? PageUrl { get; set; }
 
     /// <summary>
     /// 关怀页面Url
     /// </summary>
     [SugarColumn(ColumnDescription ="关怀页面Url")]
-    public string PageCareUrl { get; set; }
+    public string? PageCareUrl { get; set; }
 
     /// <summary>
     /// 关联宣传学习
     /// 从字典中取"公告类型"
     /// </summary>
     [SugarColumn(ColumnDescription ="关联宣传学习")]
-    public string BulletinTypePublicityId { get; set; }
+    public string? BulletinTypePublicityId { get; set; }
 
     /// <summary>
     /// 关联宣传学习
     /// 从字典中取"公告类型"
     /// </summary>
     [SugarColumn(ColumnDescription = "关联宣传学习")]
-    public string BulletinTypePublicityName { get; set; }
+    public string? BulletinTypePublicityName { get; set; }
 
     /// <summary>
     /// 关联操作指引
     /// 从字典中取"公告类型"
     /// </summary>
     [SugarColumn(ColumnDescription = "关联操作指引")]
-    public string BulletinTypeGuideId { get; set; }
+    public string? BulletinTypeGuideId { get; set; }
 
     /// <summary>
     /// 关联操作指引
     /// 从字典中取"公告类型"
     /// </summary>
     [SugarColumn(ColumnDescription = "关联操作指引")]
-    public string BulletinTypeGuideame { get; set; }
+    public string? BulletinTypeGuideame { get; set; }
 
     /// <summary>
     /// 背景图片 url
     /// </summary>
     [SugarColumn(ColumnDescription = "背景图片 url")]
-    public string BackgroundImgUrl { get; set; }
+    public string? BackgroundImgUrl { get; set; }
 
     /// <summary>
     /// Banner 图片 url
     /// </summary>
     [SugarColumn(ColumnDescription = "Banner 图片 url")]
-    public string BannerImgUrl { get; set; }
+    public string? BannerImgUrl { get; set; }
 
     /// <summary>
     /// 宫格图
     /// </summary>
     [SugarColumn(ColumnDescription = "宫格图")]
-    public string CellImgUrl { get; set; }
+    public string? CellImgUrl { get; set; }
 
     /// <summary>
     /// 关怀宫格图
     /// </summary>
     [SugarColumn(ColumnDescription = "关怀宫格图")]
-    public string CareCellImgUrl { get; set; }
+    public string? CareCellImgUrl { get; set; }
 }