From 2d25ebd7ceada2d710055a32b5a4735e2bcb791b Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 25 Apr 2022 13:41:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E7=B3=BB=E7=BB=9F=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 6 +++ .../Management/DTO/SystemNoticeViewModel.cs | 17 +++++++++ .../Service/Management/SystemNoticeService.cs | 37 ++++++++++++++++++- .../Service/Management/_MapConfig.cs | 12 +++++- .../Management/Notice/SystemNotice.cs | 2 + 5 files changed, 71 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 91c9b1cd..a09368e3 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -330,6 +330,12 @@ SystemNoticeService + + 设置已读 + + + 获取登陆用户的系统通知列表 只是过滤了用户类型 + 项目外部人员 录入流程相关 diff --git a/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs index 562b62a9..c8aa3b9d 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs @@ -17,6 +17,10 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime CreateTime { get; set; } public Guid CreateUserId { get; set; } + + public string CreateUserName { get; set; } + + public DateTime UpdateTime { get; set; } public Guid UpdateUserId { get; set; } @@ -75,6 +79,19 @@ namespace IRaCIS.Core.Application.ViewModel public Guid[] NoticeUserTypeIdList { get; set; } } + + public class SystemNoticeReadDTO: SystemNoticeBasicInfo + { + public DateTime CreateTime { get; set; } + public Guid CreateUserId { get; set; } + + public string CreateUserName { get; set; } + + public string FullFilePath { get; set; } + + public bool IsRead { get; set; } + } + public class SystemNoticeUserTypeView { public Guid Id { get; set; } diff --git a/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs b/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs index e41dc225..a9641d08 100644 --- a/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs +++ b/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs @@ -37,7 +37,7 @@ namespace IRaCIS.Core.Application.Service .WhereIf(querySystemNotice.NoticeTypeEnum != null, t => t.NoticeTypeEnum == querySystemNotice.NoticeTypeEnum) .WhereIf(!string.IsNullOrWhiteSpace(querySystemNotice.FileName), t => t.FileName.Contains(querySystemNotice.FileName)) .WhereIf(!string.IsNullOrWhiteSpace(querySystemNotice.NoticeContent), t => t.NoticeContent.Contains(querySystemNotice.NoticeContent)) - .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken}); + .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }); return await systemNoticeQueryable.ToPagedListAsync(querySystemNotice.PageIndex, querySystemNotice.PageSize, querySystemNotice.SortField, querySystemNotice.Asc); } @@ -48,7 +48,7 @@ namespace IRaCIS.Core.Application.Service if (addOrEditSystemNotice.Id == null) { - var entity = await _systemNoticeRepository.InsertFromDTOAsync(addOrEditSystemNotice,true); + var entity = await _systemNoticeRepository.InsertFromDTOAsync(addOrEditSystemNotice, true); return ResponseOutput.Ok(entity.Id.ToString()); @@ -78,5 +78,38 @@ namespace IRaCIS.Core.Application.Service } + /// 设置已读 + + public async Task SetSystemNoticeHaveRead(Guid systemNoticeId) + { + var systemNotice = (await _systemNoticeRepository.FirstOrDefaultAsync(t => t.Id == systemNoticeId)).IfNullThrowException(); + + systemNotice.NoticeUserReadList.Add(new SystemNoticeUserRead() { SystemNoticeId = systemNoticeId }); + + var success = await _systemNoticeRepository.SaveChangesAsync(); + + + return ResponseOutput.Result(success); + } + + /// 获取登陆用户的系统通知列表 只是过滤了用户类型 + [HttpPost] + public async Task> GetUserSystemNoticeList(SystemNoticeQuery querySystemNotice) + { + var systemNoticeQueryable = _systemNoticeRepository + .Where(t=>t.NoticeUserTypeList.Any(t=>t.UserTypeId==_userInfo.UserTypeId)) + .WhereIf(querySystemNotice.ApplicableProjectEnum != null, t => t.ApplicableProjectEnum == querySystemNotice.ApplicableProjectEnum) + .WhereIf(querySystemNotice.NoticeLevelEnum != null, t => t.NoticeLevelEnum == querySystemNotice.NoticeLevelEnum) + .WhereIf(querySystemNotice.NoticeModeEnum != null, t => t.NoticeModeEnum == querySystemNotice.NoticeModeEnum) + .WhereIf(querySystemNotice.NoticeStateEnum != null, t => t.NoticeStateEnum == querySystemNotice.NoticeStateEnum) + .WhereIf(querySystemNotice.NoticeTypeEnum != null, t => t.NoticeTypeEnum == querySystemNotice.NoticeTypeEnum) + .WhereIf(!string.IsNullOrWhiteSpace(querySystemNotice.FileName), t => t.FileName.Contains(querySystemNotice.FileName)) + .WhereIf(!string.IsNullOrWhiteSpace(querySystemNotice.NoticeContent), t => t.NoticeContent.Contains(querySystemNotice.NoticeContent)) + .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken ,userId=_userInfo.Id}); + + return await systemNoticeQueryable.ToPagedListAsync(querySystemNotice.PageIndex, querySystemNotice.PageSize, querySystemNotice.SortField, querySystemNotice.Asc); + } + + } } diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index e7ca22b5..acfc2f54 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -91,8 +91,18 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.CanEditUserType, u => u.MapFrom(s => !s.UserTrials.Any())); var token = string.Empty; + var userId = Guid.Empty; CreateMap() - .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token)); ; + .ForMember(t=>t.CreateUserName,d=>d.MapFrom(t=>t.CreateUser.FullName)) + .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token)); + + + + + CreateMap() + .ForMember(t => t.CreateUserName, d => d.MapFrom(t => t.CreateUser.FullName)) + .ForMember(t => t.IsRead, d => d.MapFrom(t => t.NoticeUserReadList.Any(t=>t.CreateUserId== userId))) + .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token)); CreateMap().ReverseMap() .ForMember(t=>t.NoticeUserTypeList,u=>u.MapFrom(t=>t.NoticeUserTypeIdList)); diff --git a/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs b/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs index b5eeaa54..7aefee9a 100644 --- a/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs +++ b/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs @@ -23,6 +23,8 @@ namespace IRaCIS.Core.Domain.Models public List NoticeUserReadList { get; set; } + public User CreateUser { get; set; } + /// /// NoticeContent