/// <summary> /// 获取 消息中心的 通知公告 公司新闻 事务通知 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultDto <NoticeList> > GetPage(GetNoticeListInput input) { var query = CreateNoticeQuery(input.NoticeType); if (query == null) { return(new PagedResultDto <NoticeList>(0, new List <NoticeList>())); } query = query.WhereIf(!input.SearchKey.IsNullOrWhiteSpace(), r => r.Title.Contains(input.SearchKey) || r.CreateUserName.Contains(input.SearchKey)); query = (from a in query join b in _followRepository.GetAll().Where(x => x.BusinessType == FollowType.公告 && x.CreatorUserId == AbpSession.UserId.Value) on a.LogId equals b.BusinessId into tmp1 from c in tmp1.DefaultIfEmpty() where (input.IsFollow ? c != null : true) select new NoticeList() { LogId = a.LogId, TextId = a.TextId, Title = a.Title, Content = a.Content, IsRead = a.IsRead, ProjectId = a.ProjectId, Type = a.Type, CreateUserName = a.CreateUserName, CreateUserId = a.CreateUserId, IsFollow = c != null, CreationTime = a.CreationTime } ); var total = await query.CountAsync(); var list = await query.Skip(input.SkipCount).Take(input.MaxResultCount).ToListAsync(); if (input.NoticeType == 1) { foreach (var m in list) { if (m.IsRead) { continue; } var log = await _noticeLogRepository.GetAsync(m.LogId); if (log != null) { log.Status = 2; log.ReadTime = DateTime.Now; await _noticeLogRepository.UpdateAsync(log); } } } return(new PagedResultDto <NoticeList>(total, list)); }
public async Task <PagedResultDto <NoticeList> > GetNoticeTextsAsync(GetNoticeListInput input) { var queryBase = _noticeTextRepository.GetAll().Where(a => a.NoticeType == 2); if (input.IsNew) { var newNotice = queryBase.OrderByDescending(a => a.CreationTime).FirstOrDefault(); if (newNotice != null) { queryBase = queryBase.Where(x => x.Id != newNotice.Id); } } var query = (from a in queryBase join b in _followRepository.GetAll().Where(x => x.BusinessType == FollowType.公告 && x.CreatorUserId == AbpSession.UserId.Value) on a.Id equals b.BusinessId into tmp1 from c in tmp1.DefaultIfEmpty() join d in _userRepository.GetAll() on a.CreatorUserId equals d.Id where (input.IsFollow?c != null:true) select new NoticeList() { TextId = a.Id, Title = a.Title, CreateUserName = d.Name, CreateUserId = a.CreatorUserId.Value, Content = a.MsgConent, IsFollow = c != null, CreationTime = a.CreationTime } ); if (!string.IsNullOrWhiteSpace(input.SearchKey)) { query = query.Where(r => r.Title.Contains(input.SearchKey) || r.CreateUserName.Contains(input.SearchKey)); } var count = await query.CountAsync(); var notices = await query.OrderByDescending(r => r.CreationTime).PageBy(input).ToListAsync(); return(new PagedResultDto <NoticeList>() { TotalCount = count, Items = notices }); }