Explorar el Código

随手拍公告增加字段

qinchaoyue hace 4 meses
padre
commit
d7acff50eb

+ 12 - 38
src/Hotline.Api/Controllers/Snapshot/SnapshotBulletinController.cs

@@ -12,6 +12,8 @@ using Hotline.Caching.Interfaces;
 using Hotline.Settings;
 using Hotline.Article;
 using Hotline.Snapshot;
+using Hotline.Share.Dtos.Snapshot;
+using Hotline.Share.Tools;
 
 namespace Hotline.Api.Controllers.Snapshot;
 
@@ -39,19 +41,18 @@ public class SnapshotBulletinController : BaseController
     /// <param name="dto"></param>
     /// <returns></returns>
     [HttpGet("bulletin/query")]
-    public async Task<PagedDto<BulletinDto>> QueryBulletinList([FromQuery] QueryBulletinListRequestDto dto)
+    public async Task<PagedDto<SnapshotBulletinItemsOutDto>> QueryBulletinList([FromQuery] SnapshotBulletinItemsInDto dto)
     {
-        var (total, items) = await _bulletinRepository.Queryable()
+        var query = _bulletinRepository.Queryable()
             .Includes(x => x.ExaminMan)
-            .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), d => d.SnapshotBulletinTypeId == dto.BulletinTypeId)
+            .WhereIF(!string.IsNullOrEmpty(dto.SnapshotBulletinTypeName), d => d.SnapshotBulletinTypeName.Contains(dto.SnapshotBulletinTypeName))
             .WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Title.Contains(dto.Title))
-            .WhereIF(dto.BulletinTimeStart.HasValue, d => d.BulletinTime >= dto.BulletinTimeStart)
-            .WhereIF(dto.BulletinTimeEnd.HasValue, d => d.BulletinTime <= dto.BulletinTimeEnd)
-            .WhereIF(dto.BulletinState != null, d => d.BulletinState == dto.BulletinState)
+            .WhereIF(dto.BeginCreationTime.HasValue, d => d.BulletinTime >= dto.BeginCreationTime)
+            .WhereIF(dto.EndCreationTime.HasValue, d => d.BulletinTime <= dto.EndCreationTime)
             .OrderByDescending(d => d.CreationTime)
-            .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
-
-        return new PagedDto<BulletinDto>(total, items.Adapt<IReadOnlyList<BulletinDto>>());
+            .Select<SnapshotBulletinItemsOutDto>();
+        return (await query
+            .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted)).ToPaged();
     }
 
     /// <summary>
@@ -178,42 +179,14 @@ public class SnapshotBulletinController : BaseController
     /// <param name="dto"></param>
     /// <returns></returns>
     [HttpPost("bulletin/add")]
-    public async Task AddBulletin([FromBody] AddBulletinDto dto)
+    public async Task AddBulletin([FromBody] AddSnapshotBulletinInDto dto)
     {
         var model = dto.Adapt<SnapshotBulletin>();
         model.BulletinState = Share.Enums.Article.EBulletinState.Draft;
         model.ReadedNum = 0;
-        model.IsArrive = false;
         await _bulletinRepository.AddAsync(model, HttpContext.RequestAborted);
     }
 
-    /// <summary>
-    /// 公告上架或者下架
-    /// </summary>
-    /// <param name="dto"></param>
-    /// <returns></returns>
-    [HttpPost("bulletin-arrive")]
-    public async Task BulletinArrive([FromBody] BulletinArriveDto dto)
-    {
-        var bulletin = await _bulletinRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
-        if (bulletin == null)
-            throw UserFriendlyException.SameMessage("无效数据");
-
-        if (bulletin.BulletinState != EBulletinState.ReviewPass)
-            throw UserFriendlyException.SameMessage("当前状态不能操作上架或下架");
-
-        bulletin.IsArrive = dto.IsArrive;
-        if (bulletin.IsArrive == false)
-        {
-            bulletin.ExaminTime = null;
-            bulletin.ExaminManId = null;
-            bulletin.ExaminOpinion = null;
-            bulletin.CommitTime = null;
-            bulletin.BulletinState = EBulletinState.Draft;
-        }
-        await _bulletinRepository.UpdateAsync(bulletin, HttpContext.RequestAborted);
-    }
-
     /// <summary>
     /// 列表页面基础数据
     /// </summary>
@@ -239,6 +212,7 @@ public class SnapshotBulletinController : BaseController
         var rsp = new
         {
             BulletinType = _systemDicDataCacheManager.SnapshotBulletinType,
+            BulletinSource = _systemDicDataCacheManager.SnapshotBulletinSource,
             OrgsOptions = await _organizeRepository.GetOrgJson(),
         };
         return rsp;

+ 4 - 4
src/Hotline.Application.Tests/Application/SnapshotApplicationTest.cs

@@ -98,16 +98,16 @@ public class SnapshotApplicationTest : TestBase
         {
             Title = "单元测试" + DateTime.Now.ToLongDateTimeString(),
             Content = "测试内容" + DateTime.Now.ToLongDateTimeString(),
-            SnapshotBulletinTypeId = industry.BulletinTypeGuideId!,
-            SnapshotBulletinTypeName = industry.BulletinTypeGuideName!
+            BulletinTypeId = industry.BulletinTypeGuideId!,
+            BulletinTypeName = industry.BulletinTypeGuideName!
         };
         var bulletinId = await _snapshotApplication.AddBulletinAsync(inDto);
         inDto = new AddSnapshotBulletinInDto
         {
             Title = "单元测试" + DateTime.Now.ToLongDateTimeString(),
             Content = "测试内容" + DateTime.Now.ToLongDateTimeString(),
-            SnapshotBulletinTypeId = industry.BulletinTypePublicityId!,
-            SnapshotBulletinTypeName = industry.BulletinTypePublicityName!
+            BulletinTypeId = industry.BulletinTypePublicityId!,
+            BulletinTypeName = industry.BulletinTypePublicityName!
         };
         bulletinId = await _snapshotApplication.AddBulletinAsync(inDto);
         await _snapshotApplication.AuditBulletinAsync(new ExamineBulletinDto { Id = bulletinId, IsPass = true, Reason = "测试审核通过"});

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

@@ -16,6 +16,10 @@ public class SnapshotMapperConfigs : IRegister
 {
     public void Register(TypeAdapterConfig config)
     {
+        config.ForType<AddSnapshotBulletinInDto, SnapshotBulletin>()
+            .Map(m => m.SnapshotBulletinTypeId, n => n.BulletinTypeId)
+            .Map(m => m.SnapshotBulletinTypeName, n => n.BulletinTypeName);
+
         config.ForType<GuiderSystemInDto, CommunityInfo>()
             .Map(dest => dest.Name, src => src.OrgName)
             .Map(dest => dest.ParentCode, src => src.ParentOrgId)

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

@@ -184,7 +184,7 @@ public abstract class SnapshotApplicationBase
             ?? throw UserFriendlyException.SameMessage("行业不存在:" + id);
 
         var bulletinId = await _bulletinRepository.Queryable()
-            .Where(m => m.SnapshotBulletinTypeId == indurstry.BulletinTypeGuideId && m.BulletinState == EBulletinState.ReviewPass && m.IsArrive == true)
+            .Where(m => m.SnapshotBulletinTypeId == indurstry.BulletinTypeGuideId && m.BulletinState == EBulletinState.ReviewPass)
             .OrderByDescending(m => m.CreationTime)
             .Select(m => m.Id)
             .FirstAsync(requestAborted);

+ 181 - 3
src/Hotline.Share/Dtos/Snapshot/SnapshotBulletinDto.cs

@@ -1,15 +1,148 @@
-using System;
+using Hotline.Share.Dtos.Users;
+using Hotline.Share.Enums.Article;
+using Hotline.Share.Requests;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using XF.Utility.EnumExtensions;
 
 namespace Hotline.Share.Dtos.Snapshot;
+
+
 class SnapshotBulletinDto
 {
 }
 
+/// <summary>
+/// 入参
+/// </summary>
+/// <param name="SnapshotBulletinTypeName">列表名称</param>
+/// <param name="Title">标题</param>
+/// <param name="No">文档编号</param>
+/// <param name="DepartmentName">部门</param>
+/// <param name="CreatorName">发布人</param>
+/// <param name="BeginCreationTime">发布开始时间</param>
+/// <param name="EndCreationTime">发布结束时间</param>
+public record SnapshotBulletinItemsInDto(string? SnapshotBulletinTypeName, string? Title, 
+    string? No,
+    string? DepartmentName,
+    string? CreatorName,
+    DateTime? BeginCreationTime,
+    DateTime? EndCreationTime) : PagedRequest;
+
+public class SnapshotBulletinItemsOutDto
+{
+    public string Id { get; set; }
+
+    public DateTime CreationTime { get; set; }
+
+    public string Title { get; set; }
+
+    public string Content { get; set; }
+
+    /// <summary>
+    /// 字典中添加类型Id
+    /// </summary>
+    public string SnapshotBulletinTypeId { get; set; }
+
+    /// <summary>
+    /// 系统字典中添加类型名称
+    /// </summary>
+    public string SnapshotBulletinTypeName { get; set; }
+
+    /// <summary>
+    /// 阅读量
+    /// </summary>
+    public int ReadedNum { get; set; }
+
+    /// <summary>
+    /// 通知时间
+    /// </summary>
+    public DateTime? BulletinTime { get; set; }
+
+    /// <summary>
+    /// 公告状态
+    /// </summary>
+    public EBulletinState BulletinState { get; set; }
+
+    /// <summary>
+    /// 来源单位ID
+    /// </summary>
+    public string SourceOrgId { get; set; }
+
+    /// <summary>
+    /// 来源单位名称
+    /// </summary>
+    public string SourceOrgName { get; set; }
+
+    /// <summary>
+    /// 创建人
+    /// </summary>
+    public string? CreatorId { get; set; }
+
+    public string? CreatorName { get; set; }
+
+    /// <summary>
+    /// 提交时间
+    /// </summary>
+    public DateTime? CommitTime { get; set; }
+
+    /// <summary>
+    /// 审核意见
+    /// </summary>
+    public string? ExaminOpinion { get; set; }
+
+    /// <summary>
+    /// 审核人
+    /// </summary>
+    public string? ExaminManId { get; set; }
+
+    /// <summary>
+    /// 审核人
+    /// </summary>
+    public UserDto? ExaminMan { get; set; }
+
+    /// <summary>
+    /// 审核时间
+    /// </summary>
+    public DateTime? ExaminTime { get; set; }
+
+    public string BulletinStateText => BulletinState.GetDescription();
+
+    /// <summary>
+    /// 是否公开
+    /// </summary>
+    public bool? IsOpen { get; set; }
+
+    /// <summary>
+    /// 是否加粗
+    /// </summary>
+    public bool? IsBold { get; set; }
+
+    /// <summary>
+    /// 网站公开
+    /// </summary>
+    public bool? IsOpenWebsite { get; set; }
+
+    /// <summary>
+    /// 微博公开
+    /// </summary>
+    public bool? IsWeibo { get; set; }
+
+    /// <summary>
+    /// 微信公开
+    /// </summary>
+    public bool? IsWeChat { get; set; }
+
+    /// <summary>
+    /// 是否置顶
+    /// </summary>
+    public bool? IsTop { get; set; }
+}
+
 public class AddSnapshotBulletinInDto
 {
     /// <summary>
@@ -28,11 +161,56 @@ public class AddSnapshotBulletinInDto
     /// 公告类型
     /// </summary>
     [Required]
-    public string SnapshotBulletinTypeId { get; set; }
+    public string BulletinTypeId { get; set; }
 
     /// <summary>
     /// 公告类型名称
     /// </summary>
     [Required]
-    public string SnapshotBulletinTypeName { get; set; }
+    public string BulletinTypeName { get; set; }
+
+    /// <summary>
+    /// 文档编号
+    /// </summary>
+    public string? No { get; set; }
+
+    /// <summary>
+    /// 来源单位ID
+    /// </summary>
+    public string SourceOrgId { get; set; }
+
+    /// <summary>
+    /// 来源单位名称
+    /// </summary>
+    public string SourceOrgName { get; set; }
+
+    /// <summary>
+    /// 是否公开
+    /// </summary>
+    public bool? IsOpen { get; set; }
+
+    /// <summary>
+    /// 是否加粗
+    /// </summary>
+    public bool? IsBold { get; set; }
+
+    /// <summary>
+    /// 网站公开
+    /// </summary>
+    public bool? IsOpenWebsite { get; set; }
+
+    /// <summary>
+    /// 微博公开
+    /// </summary>
+    public bool? IsWeibo { get; set; }
+
+    /// <summary>
+    /// 微信公开
+    /// </summary>
+    public bool? IsWeChat { get; set; }
+
+    /// <summary>
+    /// 是否置顶
+    /// </summary>
+    public bool? IsTop { get; set; }
 }

+ 9 - 4
src/Hotline/Caching/Interfaces/ISysDicDataCacheManager.cs

@@ -47,13 +47,18 @@ namespace Hotline.Caching.Interfaces
         /// 随手拍公告类型
         /// </summary>
         IReadOnlyList<SystemDicDataOutDto> SnapshotBulletinType { get; }
-        public IReadOnlyList<SystemDicDataOutDto> WorkArea { get; }
-        public IReadOnlyList<SystemDicData> VisitMananer { get; }
-        public IReadOnlyList<SystemDicData> SourceChannel { get; }
+        IReadOnlyList<SystemDicDataOutDto> WorkArea { get; }
+        IReadOnlyList<SystemDicData> VisitMananer { get; }
+        IReadOnlyList<SystemDicData> SourceChannel { get; }
 
         /// <summary>
         /// 自贡随手拍行业审批部门
         /// </summary>
-        public IReadOnlyCollection<SystemDicDataOutDto> SnapshotDepartment { get; }
+        IReadOnlyCollection<SystemDicDataOutDto> SnapshotDepartment { get; }
+
+        /// <summary>
+        /// 随手拍公告来源
+        /// </summary>
+        IReadOnlyCollection<SystemDicDataOutDto> SnapshotBulletinSource { get; }
     }
 }

+ 5 - 0
src/Hotline/Caching/Services/SysDicDataCacheManager.cs

@@ -117,6 +117,11 @@ namespace Hotline.Caching.Services
         /// </summary>
         public IReadOnlyCollection<SystemDicDataOutDto> SnapshotDepartment => GetOrAdd(SysDicTypeConsts.SnapshotDepartment);
 
+        /// <summary>
+        /// 随手拍公告来源
+        /// </summary>
+        public IReadOnlyCollection<SystemDicDataOutDto> SnapshotBulletinSource => GetOrAdd(SysDicTypeConsts.SnapshotBulletinSource);
+
 
         public void RemoveSysDicDataCache(string code)
         {

+ 11 - 0
src/Hotline/SeedData/SystemDicDataSeedData.cs

@@ -17,6 +17,13 @@ public class SystemDicDataSeedData : ISeedData<SystemDicData>
 
     public IEnumerable<SystemDicData> GetData(string dicTypeCode)
     {
+        if (dicTypeCode == SysDicTypeConsts.SnapshotBulletinSource)
+        {
+            return [
+                new() { Id = "08dcc33d-91a1-4a69-8262-7d058681f266", DicDataValue = "1", DicDataName = "自建", Sort = 1},
+                new() { Id = "08dd0eca-66b8-4c98-8dec-0c76c29d77e3", DicDataValue = "2", DicDataName = "外部", Sort = 2},
+                ];
+        }
         if (dicTypeCode == SysDicTypeConsts.SnapshotDepartment)
         {
             return [
@@ -176,6 +183,10 @@ public class SystemDicDataSeedData : ISeedData<SystemDicData>
         {
             dicType = ["08dd1f5d-ebd8-4dc1-861c-d3190ad4c528", "随手拍审核部门"];
         }
+        if (dicTypeCode == SysDicTypeConsts.SnapshotBulletinSource)
+        {
+            dicType = ["08dd060d-e27b-4786-879b-0469d6629d38", "随手拍公告来源"];
+        }
 
         return new SystemDicType
         {

+ 5 - 0
src/Hotline/Settings/SysDicTypeConsts.cs

@@ -296,4 +296,9 @@ public class SysDicTypeConsts
     /// 自贡随手拍行业审批部门
     /// </summary>
     public const string SnapshotDepartment = "SnapshotDepartment";
+
+    /// <summary>
+    /// 随手拍公告来源
+    /// </summary>
+    public const string SnapshotBulletinSource = "SnapshotBulletinSource";
 }

+ 55 - 3
src/Hotline/Snapshot/SnapshotBulletin.cs

@@ -15,8 +15,20 @@ public class SnapshotBulletin : CreationEntity
     /// <summary>
     /// 标题
     /// </summary>
+    [SugarColumn(ColumnDescription = "标题")]
     public string Title { get; set; }
 
+    /// <summary>
+    /// No
+    /// </summary>
+    [SugarColumn(ColumnDescription = "No")]
+    public string? No { get; set; }
+
+    /// <summary>
+    /// 部门名称
+    /// </summary>
+    public string? DepartmentName { get; set; }
+
     /// <summary>
     /// 内容
     /// </summary>
@@ -26,36 +38,43 @@ public class SnapshotBulletin : CreationEntity
     /// <summary>
     /// 字典中添加类型Id
     /// </summary>
+    [SugarColumn(ColumnDescription = "字典中添加类型Id")]
     public string SnapshotBulletinTypeId { get; set; }
 
     /// <summary>
     /// 系统字典中添加类型名称
     /// </summary>
+    [SugarColumn(ColumnDescription = "系统字典中添加类型名称")]
     public string SnapshotBulletinTypeName { get; set; }
 
     /// <summary>
     /// 阅读量
     /// </summary>
+    [SugarColumn(ColumnDescription = "阅读量")]
     public int ReadedNum { get; set; }
 
     /// <summary>
     /// 公告状态
     /// </summary>
+    [SugarColumn(ColumnDescription = "公告状态")]
     public EBulletinState BulletinState { get; set; }
 
     /// <summary>
     /// 提交时间
     /// </summary>
+    [SugarColumn(ColumnDescription = "提交时间")]
     public DateTime? CommitTime { get; set; }
 
     /// <summary>
     /// 审核意见
     /// </summary>
+    [SugarColumn(ColumnDescription = "审核意见")]
     public string? ExaminOpinion { get; set; }
 
     /// <summary>
     /// 审核人
     /// </summary>
+    [SugarColumn(ColumnDescription = "审核人")]
     public string? ExaminManId { get; set; }
 
     /// <summary>
@@ -67,22 +86,55 @@ public class SnapshotBulletin : CreationEntity
     /// <summary>
     /// 审核时间
     /// </summary>
+    [SugarColumn(ColumnDescription = "审核时间")]
     public DateTime? ExaminTime { get; set; }
 
     /// <summary>
-    /// 是否上架
+    /// 是否公开
+    /// </summary>
+    [SugarColumn(ColumnDescription = "是否公开")]
+    public bool? IsOpen { get; set; }
+
+    /// <summary>
+    /// 是否加粗
+    /// </summary>
+    [SugarColumn(ColumnDescription = "是否加粗")]
+    public bool? IsBold { get; set; }
+
+    /// <summary>
+    /// 网站公开
+    /// </summary>
+    [SugarColumn(ColumnDescription = "网站公开")]
+    public bool? IsOpenWebsite { get; set; }
+
+    /// <summary>
+    /// 微博公开
+    /// </summary>
+    [SugarColumn(ColumnDescription = "微博公开")]
+    public bool? IsWeibo { get; set; }
+
+    /// <summary>
+    /// 微信公开
+    /// </summary>
+    [SugarColumn(ColumnDescription = "微信公开")]
+    public bool? IsWeChat { get; set; }
+
+    /// <summary>
+    /// 是否置顶
     /// </summary>
-    public bool? IsArrive { get; set; }
+    [SugarColumn(ColumnDescription = "是否置顶")]
+    public bool? IsTop { get; set; }
 
     /// <summary>
     /// 是否弹窗
     /// </summary>
-    [SugarColumn(DefaultValue = "f")]
+    [SugarColumn(DefaultValue = "f", ColumnDescription = "是否弹窗")]
     public bool IsPopup { get; set; }
 
     /// <summary>
     /// 通知时间
     /// </summary>
+    [SugarColumn(ColumnDescription = "通知时间")]
     public DateTime? BulletinTime { get; set; }
 
     /// <summary>