diff --git a/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs index c8aa3b9d2..0c3fb3d00 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/SystemNoticeViewModel.cs @@ -14,6 +14,12 @@ namespace IRaCIS.Core.Application.ViewModel /// SystemNoticeView 列表视图模型 public class SystemNoticeView : SystemNoticeBasicInfo { + public Guid? PublishedUserId { get; set; } + + public DateTime? PublishedTime { get; set; } + + public string PublishUserName { get; set; } + public DateTime CreateTime { get; set; } public Guid CreateUserId { get; set; } diff --git a/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs b/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs index ba694b757..2f1d0abe3 100644 --- a/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs +++ b/IRaCIS.Core.Application/Service/Management/SystemNoticeService.cs @@ -48,8 +48,14 @@ namespace IRaCIS.Core.Application.Service if (addOrEditSystemNotice.Id == null) { - var entity = await _systemNoticeRepository.InsertFromDTOAsync(addOrEditSystemNotice, true); + var entity = await _systemNoticeRepository.InsertFromDTOAsync(addOrEditSystemNotice); + if (entity.NoticeStateEnum == Domain.Share.Management.SystemNotice_NoticeStateEnum.HavePublished) + { + entity.PublishedUserId = _userInfo.Id; + entity.PublishedTime = DateTime.Now; + } + _systemNoticeRepository.SaveChangesAsync(); return ResponseOutput.Ok(entity.Id.ToString()); } @@ -60,6 +66,18 @@ namespace IRaCIS.Core.Application.Service _mapper.Map(addOrEditSystemNotice, systemNotice); + if (addOrEditSystemNotice.NoticeStateEnum == Domain.Share.Management.SystemNotice_NoticeStateEnum.HavePublished && systemNotice.NoticeStateEnum == Domain.Share.Management.SystemNotice_NoticeStateEnum.NotPublish) + { + systemNotice.PublishedUserId = _userInfo.Id; + systemNotice.PublishedTime = DateTime.Now; + } + else + { + systemNotice.PublishedUserId = null; + systemNotice.PublishedTime = null; + } + + await _systemNoticeRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -97,7 +115,7 @@ namespace IRaCIS.Core.Application.Service public async Task> GetUserSystemNoticeList(SystemNoticeQuery querySystemNotice) { var systemNoticeQueryable = _systemNoticeRepository - .Where(t=>t.NoticeUserTypeList.Any(t=>t.UserTypeId==_userInfo.UserTypeId)) + .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) @@ -105,7 +123,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 ,userId=_userInfo.Id}); + .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 891c9005f..02a06a1a2 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -11,8 +11,8 @@ namespace IRaCIS.Core.Application.Service { public ManagementConfig() { - - CreateMap().IncludeMembers(t => t.Menu); + + CreateMap().IncludeMembers(t => t.Menu); @@ -27,13 +27,13 @@ namespace IRaCIS.Core.Application.Service CreateMap().ForMember(t => t.DictionaryId, u => u.MapFrom(c => c)) .EqualityComparison((odto, o) => odto == o.DictionaryId); - CreateMap().ForMember(t=>t.MenuId,u=>u.MapFrom(c=>c)) + CreateMap().ForMember(t => t.MenuId, u => u.MapFrom(c => c)) .EqualityComparison((odto, o) => odto == o.MenuId); CreateMap() .ForMember(t => t.GroupName, u => u.MapFrom(c => c.Group.Value)) .ForMember(t => t.GroupNameCN, u => u.MapFrom(c => c.Group.ValueCN)); - + CreateMap().ForMember(d => d.Id, u => u.MapFrom(t => t.MenuId)).ReverseMap(); @@ -44,7 +44,7 @@ namespace IRaCIS.Core.Application.Service CreateMap() - .ForMember(t => t.MenuIds, u => u.MapFrom(c => c.UserTypeMenuList.Select(t=>t.MenuId))); + .ForMember(t => t.MenuIds, u => u.MapFrom(c => c.UserTypeMenuList.Select(t => t.MenuId))); CreateMap(); CreateMap(); @@ -93,23 +93,24 @@ namespace IRaCIS.Core.Application.Service var token = string.Empty; var userId = Guid.Empty; CreateMap() - .ForMember(t=>t.CreateUserName,d=>d.MapFrom(t=>t.CreateUser.FullName)) + .ForMember(t => t.PublishUserName, d => d.MapFrom(t => t.PublishUser.FullName)) + .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(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)); + .ForMember(t => t.NoticeUserTypeList, u => u.MapFrom(t => t.NoticeUserTypeIdList)); - CreateMap().IncludeMembers(t=>t.NoticeUserType) - .ForMember(t=>t.Id,u=>u.MapFrom(u=>u.NoticeUserType.Id)); + CreateMap().IncludeMembers(t => t.NoticeUserType) + .ForMember(t => t.Id, u => u.MapFrom(u => u.NoticeUserType.Id)); CreateMap(); @@ -120,5 +121,5 @@ namespace IRaCIS.Core.Application.Service } } - + } diff --git a/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs b/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs index 7aefee9a8..811cc5e2b 100644 --- a/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs +++ b/IRaCIS.Core.Domain/Management/Notice/SystemNotice.cs @@ -73,18 +73,18 @@ namespace IRaCIS.Core.Domain.Models public DateTime? EndDate { get; set; } - /// - /// FileName - /// [Required] public string FileName { get; set; } - /// - /// Path - /// [Required] public string Path { get; set; } + public Guid? PublishedUserId { get; set; } + + public User PublishUser { get; set; } + + public DateTime? PublishedTime { get; set; } + } }