Browse Source

Merge branch 'master' of http://110.188.24.182:10023/Fengwo/hotline

田爽 1 year ago
parent
commit
514a8e97d9

+ 142 - 0
src/Hotline.Api/Controllers/ArticleController.cs

@@ -0,0 +1,142 @@
+using Hotline.Application.FlowEngine;
+using Hotline.Article;
+using Hotline.FlowEngine.WfModules;
+using Hotline.Permissions;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Settings;
+using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Article;
+using Hotline.Share.Dtos.FlowEngine;
+using Hotline.Share.Dtos.Order;
+using Hotline.Share.Enums.Article;
+using MapsterMapper;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.OpenApi.Writers;
+using XF.Domain.Exceptions;
+using XF.Domain.Repository;
+using XF.Utility.EnumExtensions;
+
+namespace Hotline.Api.Controllers
+{
+
+    public class ArticleController: BaseController
+    {
+        private readonly IRepository<Bulletin> _bulletinRepository;
+        private readonly IMapper _mapper;
+        private readonly ISystemDomainService _systemDomainService;
+        private readonly ISystemOrganizeRepository _organizeRepository;
+        private readonly IWorkflowApplication _workflowApplication;
+
+        public ArticleController(IRepository<Bulletin> bulletinRepository,IMapper mapper, ISystemDomainService systemDomainService, ISystemOrganizeRepository organizeRepository, IWorkflowApplication workflowApplication)
+        {
+            _bulletinRepository = bulletinRepository;
+            _mapper = mapper;
+            _systemDomainService = systemDomainService;
+            _organizeRepository = organizeRepository;
+            _workflowApplication = workflowApplication;
+        }
+
+        #region 公告
+
+        /// <summary>
+        /// 查询公告列表
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [Permission(EPermission.QueryBulletinList)]
+        [HttpGet("bulletin/query")]
+        public async Task<PagedDto<BulletinDto>> QueryBulletinList([FromQuery]QueryBulletinListRequestDto dto)
+        {
+            var (total,items) = await _bulletinRepository.Queryable()
+                .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), d => d.BulletinTypeId == dto.BulletinTypeId)
+                .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)
+                .OrderByDescending(d => d.CreationTime)
+                .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
+
+            return new PagedDto<BulletinDto>(total, _mapper.Map<IReadOnlyList<BulletinDto>>(items));
+        }
+
+        /// <summary>
+        /// 公告详情(内部)
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [Permission(EPermission.BulletinEntity)]
+        [HttpGet("bulletin/entity/{id}")]
+        public async Task<BulletinDto> BulletinEntity(string id)
+        {
+            var model = await _bulletinRepository.Queryable()
+                .FirstAsync(x=>x.Id == id, HttpContext.RequestAborted);
+            return _mapper.Map<BulletinDto>(model);
+        }
+
+        /// <summary>
+        /// 新增公告
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [Permission(EPermission.AddBulletin)]
+        [HttpPost("bulletin/add")]
+        public async Task AddBulletin([FromBody]BulletinFlowDto dto)
+        {
+
+            var model = _mapper.Map<Bulletin>(dto.Data);
+            model.BulletinState = Share.Enums.Article.EBulletinState.InReview;
+            model.ReadedNum = 0;
+            var id = await _bulletinRepository.AddAsync(model, HttpContext.RequestAborted);
+            try
+            {
+                var startDto = _mapper.Map<StartWorkflowDto>(dto.Workflow);
+                startDto.DefinitionModuleCode = WorkflowModuleConsts.BulletinApply;
+                startDto.Title = model.Title;
+                await _workflowApplication.StartWorkflowAsync(startDto, id, HttpContext.RequestAborted);
+            }
+            catch (Exception ex)
+            {
+                await _bulletinRepository.RemoveAsync(id, false, HttpContext.RequestAborted);
+                throw new UserFriendlyException($"新增公告流程失败!,{ex.Message}", "新增公告流程失败");
+            }
+        }
+
+        /// <summary>
+        /// 列表页面基础数据
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("bulletin/listbasedata")]
+        public async Task<object> BulletinListBaseData()
+        {
+            var rsp = new
+            {
+                BulletinType = _systemDomainService.GetSysDicDataByCodeAsync(SysDicTypeConsts.BulletinType)
+            };
+            return rsp;
+        }
+
+        /// <summary>
+        /// 新增页面基础数据
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("bulletin/addbasedata")]
+        public async Task<object> BulletinAddBaseData()
+        {
+            var rsp = new
+            {
+                BulletinType = _systemDomainService.GetSysDicDataByCodeAsync(SysDicTypeConsts.BulletinType),
+                PushRanges = EnumExts.GetDescriptions<EPushRange>(),
+                OrgsOptions = await _organizeRepository.GetOrgJson(),
+            };
+            return rsp;
+        }
+
+
+        #endregion
+
+        #region 通知
+
+
+        #endregion
+
+    }
+}

+ 1 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -599,7 +599,7 @@ public class OrderController : BaseController
     /// <returns></returns>
     [Permission(EPermission.CanDelayOrderList)]
     [HttpGet("candelay")]
-    public async Task<PagedDto<OrderDto>> CanDelayOrderList([FromQuery] CanDelayOrderListDto dto)
+    public async Task<PagedDto<OrderDto>> CanDelayOrderList([FromQuery]CanDelayOrderListDto dto)
     {
         var (total, items) = await _orderRepository.Queryable()
             .Includes(d => d.Acceptor)

+ 142 - 0
src/Hotline.Share/Dtos/Article/BulletinDto.cs

@@ -0,0 +1,142 @@
+using Hotline.Share.Enums.Article;
+using Hotline.Share.Requests;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Dtos.Article
+{
+    public record BulletinDto
+    {
+        public string Id { get; set; }
+
+        public DateTime CreationTime { get; set; }
+
+        public string Title { get; set; }
+
+        public string Content { get; set; }
+
+        public string BulletinTypeId { get; set; }
+
+        public string BulletinTypeName { get; set; }
+
+        /// <summary>
+        /// 阅读量
+        /// </summary>
+        public int ReadedNum { get; set; }
+
+        /// <summary>
+        /// 通知时间
+        /// </summary>
+        public DateTime? BulletinTime { get; set; }
+
+        /// <summary>
+        /// 失效时间
+        /// </summary>
+        public DateTime LoseEfficacyTime { get; set; }
+
+        /// <summary>
+        /// 公告状态
+        /// </summary>
+        public EBulletinState BulletinState { get; set; }
+
+        /// <summary>
+        /// 发布范围(多选)
+        /// </summary>
+        public EPushRange PushRanges { get; set; }
+
+        /// <summary>
+        /// 来源单位ID
+        /// </summary>
+        public string SourceOrgId { get; set; }
+
+        /// <summary>
+        /// 来源单位名称
+        /// </summary>
+        public string SourceOrgName { get; set; }
+
+        /// <summary>
+        /// 组织Id
+        /// </summary>
+        public string? CreatorOrgId { get; set; }
+
+        public string? CreatorOrgName { get; set; }
+
+        /// <summary>
+        /// 创建人
+        /// </summary>
+        public string? CreatorId { get; set; }
+
+        public string? CreatorName { get; set; }
+    }
+
+
+    public record AddBulletinDto
+    {
+        /// <summary>
+        /// 标题
+        /// </summary>
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 公告类型
+        /// </summary>
+        public string BulletinTypeId { get; set; }
+
+        /// <summary>
+        /// 公告类型名称
+        /// </summary>
+        public string BulletinTypeName { get; set; }
+
+        /// <summary>
+        /// 失效时间
+        /// </summary>
+        public DateTime LoseEfficacyTime { get; set; }
+
+        /// <summary>
+        /// 发布范围
+        /// </summary>
+        public EPushRange PushRanges { get; set; }
+
+        /// <summary>
+        /// 来源单位ID
+        /// </summary>
+        public string SourceOrgId { get; set; }
+
+        /// <summary>
+        /// 来源单位名称
+        /// </summary>
+        public string SourceOrgName { get; set; }
+    }
+
+
+    public record QueryBulletinListRequestDto:PagedRequest
+    {
+        /// <summary>
+        /// 标题
+        /// </summary>
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 通知类型
+        /// </summary>
+        public string BulletinTypeId { get; set; }
+
+        /// <summary>
+        /// 开始时间
+        /// </summary>
+        public DateTime? BulletinTimeStart { get; set; }
+
+        /// <summary>
+        /// 结束时间
+        /// </summary>
+        public DateTime? BulletinTimeEnd { get; set; }
+    }
+}

+ 6 - 0
src/Hotline.Share/Dtos/Order/OrderStartFlowDto.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Hotline.Share.Dtos.Article;
 using Hotline.Share.Dtos.FlowEngine;
 
 namespace Hotline.Share.Dtos.Order
@@ -21,4 +22,9 @@ namespace Hotline.Share.Dtos.Order
     {
 
     }
+
+    public class BulletinFlowDto:StartWorkflowDto<AddBulletinDto>
+    {
+
+    }
 }

+ 30 - 0
src/Hotline.Share/Enums/Article/EBulletinState.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Enums.Article
+{
+    public enum EBulletinState
+    {
+        /// <summary>
+        /// 审批中
+        /// </summary>
+        [Description("审批中")]
+        InReview  = 1,
+
+        /// <summary>
+        /// 审批通过
+        /// </summary>
+        [Description("审批通过")]
+        ReviewPass = 2,
+
+        /// <summary>
+        /// 审批驳回
+        /// </summary>
+        [Description("审批驳回")]
+        ReviewNoPass = 3,
+    }
+}

+ 34 - 0
src/Hotline.Share/Enums/Article/EPushRange.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Enums.Article
+{
+    [Flags]
+    public enum EPushRange
+    {
+        /// <summary>
+        /// 微信小程序
+        /// </summary>
+        [Description("微信小程序")]
+        WxApp = 1,
+        /// <summary>
+        /// 门户网站
+        /// </summary>
+        [Description("门户网站")]
+        WebSite = 2,
+        /// <summary>
+        /// 市民APP
+        /// </summary>
+        [Description("市民APP")]
+        ResidentsApp = 3,
+        /// <summary>
+        /// 部门APP
+        /// </summary>
+        [Description("部门APP")]
+        OrgApp = 4,
+    }
+}

+ 63 - 0
src/Hotline/Article/Bulletin.cs

@@ -0,0 +1,63 @@
+using Hotline.Settings;
+using Hotline.Settings.Hotspots;
+using Hotline.Share.Enums.Article;
+using SqlSugar;
+using XF.Domain.Repository;
+
+namespace Hotline.Article
+{
+    public class Bulletin : CreationEntity
+    {
+        public string Title { get; set; }
+
+        [SugarColumn(ColumnDataType = "varchar(2000)")]
+        public string Content { get; set; }
+
+        public string BulletinTypeId { get; set; }
+
+        public string BulletinTypeName { get; set; }
+
+        /// <summary>
+        /// 阅读量
+        /// </summary>
+        public int ReadedNum { get; set; }
+
+        /// <summary>
+        /// 通知时间
+        /// </summary>
+        public DateTime? BulletinTime { get; set; }
+
+        /// <summary>
+        /// 失效时间
+        /// </summary>
+        public DateTime LoseEfficacyTime { get; set; }
+
+        /// <summary>
+        /// 公告状态
+        /// </summary>
+        public EBulletinState BulletinState { get; set; }
+
+        /// <summary>
+        /// 发布范围(多选)
+        /// </summary>
+        public EPushRange PushRanges { get; set; }
+
+        /// <summary>
+        /// 来源单位ID
+        /// </summary>
+        public string SourceOrgId { get; set; }
+
+       /// <summary>
+       /// 来源单位名称
+       /// </summary>
+        public string SourceOrgName { get; set; }
+
+        /// <summary>
+        /// 阅读量+1
+        /// </summary>
+        public void Read()
+        {
+            ReadedNum++;
+        }
+    }
+}

+ 6 - 0
src/Hotline/FlowEngine/WfModules/WorkflowModuleConsts.cs

@@ -47,6 +47,11 @@ public class WorkflowModuleConsts
     /// </summary>
     public const string TelRestApply = "TelRestApply";
 
+    /// <summary>
+    /// 公告审批
+    /// </summary>
+    public const string BulletinApply = "BulletinApply";
+
     public static List<WorkflowModule> AllModules =>
         new()
         {
@@ -58,5 +63,6 @@ public class WorkflowModuleConsts
             new(OrderDelay,"工单延期"),
             new(OrderPrevious,"工单退回"),
             new(OrderScreen,"工单甄别"),
+            new(BulletinApply,"公告审批")
         };
 }

+ 29 - 7
src/Hotline/Permissions/EPermission.cs

@@ -1096,7 +1096,7 @@ namespace Hotline.Permissions
         /// </summary>
         [Display(GroupName = "OrderScreen", Name = "甄别详情", Description = "甄别详情")]
 		ScreenEntity = 500804,
-		#endregion
+        #endregion
 
 		#region 质检管理
 
@@ -1229,12 +1229,34 @@ namespace Hotline.Permissions
 
 		#endregion
 
-		#region 公用(999)
-		#region 上/下班
-		/// <summary>
-		/// 上班
-		/// </summary>
-		[Display(GroupName = "公用", Name = "上班", Description = "上班")]
+        #region 辅助功能(600)
+        [Display(GroupName = "辅助功能", Name = "辅助功能", Description = "辅助功能")]
+        Auxiliary = 600000,
+
+
+        /// <summary>
+        /// 查询公告列表
+        /// </summary>
+        [Display(GroupName = "QueryBulletinList",Name ="查询公告列表",Description ="查询公告列表")]
+        QueryBulletinList = 600100,
+        /// <summary>
+        /// 公告详情
+        /// </summary>
+        [Display(GroupName = "BulletinEntity",Name ="公告详情",Description ="公告详情")]
+        BulletinEntity = 600101,
+        /// <summary>
+        /// 新增公告
+        /// </summary>
+        [Display(GroupName = "AddBulletin",Name ="新增公告",Description ="新增公告")]
+        AddBulletin = 600102,
+        #endregion
+
+        #region 公用(999)
+        #region 上/下班
+        /// <summary>
+        /// 上班
+        /// </summary>
+        [Display(GroupName = "公用", Name = "上班", Description = "上班")]
         OnDuty = 999101,
         /// <summary>
         /// 下班

+ 9 - 4
src/Hotline/Settings/SysDicTypeConsts.cs

@@ -140,10 +140,10 @@ public class SysDicTypeConsts
     /// </summary>
     public const string FileClassify = "FileClassify";
 
-	/// <summary>
-	/// 甄别申请类型
-	/// </summary>
-	public const string ScreenType = "ScreenType";
+    /// <summary>
+    /// 甄别申请类型
+    /// </summary>
+    public const string ScreenType = "ScreenType";
 
     /// <summary>
     /// 工单受理类型
@@ -159,4 +159,9 @@ public class SysDicTypeConsts
 	/// 违禁词属性
 	/// </summary>
 	public const string ProhibitedType = "ProhibitedType";
+
+    /// <summary>
+    /// 公告类型
+    /// </summary>      
+    public const string BulletinType = "BulletinType";
 }