/// <summary> /// 获取用户订阅的通知消息信息 /// </summary> /// <param name="model"></param> /// <param name="pagingDto"></param> /// <returns></returns> public virtual async Task <IQueryable <SysUserNotificationInfo> > GetUserNotificationsAsync(SysUserNotificationInfo model) { using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete)) { var query = from userNotificationInfo in base.Context.UserNotificationInfos join userInfo in base.Context.UserInfos on userNotificationInfo.UserId equals userInfo.Id join tenantNotificationInfo in base.Context.TenantNotificationInfos on userNotificationInfo.TenantNotificationId equals tenantNotificationInfo.Id where userNotificationInfo.UserId == model.UserId && (model.State == null || userNotificationInfo.State == model.State.Value) && (model.NotificationName == null || tenantNotificationInfo.NotificationName == model.NotificationName) //取消排序,由主查询进行处理 //orderby tenantNotificationInfo.CreationTime descending select new SysUserNotificationInfo { Id = userNotificationInfo.Id, UserCode = userInfo.UserCode, UserNameCn = userInfo.UserNameCn, Severity = tenantNotificationInfo.Severity, CreatorUserId = tenantNotificationInfo.CreatorUserId, CreationTime = tenantNotificationInfo.CreationTime, TenantId = userNotificationInfo.TenantId, UserId = userNotificationInfo.UserId, Data = tenantNotificationInfo.Data, NotificationName = tenantNotificationInfo.NotificationName, DataTypeName = tenantNotificationInfo.DataTypeName, EntityTypeName = tenantNotificationInfo.EntityTypeName, EntityTypeAssemblyQualifiedName = tenantNotificationInfo.EntityTypeAssemblyQualifiedName, EntityId = tenantNotificationInfo.EntityId, State = userNotificationInfo.State }; return(await Task.FromResult(query)); } }
/// <summary> /// 获取通知 NotificationName 相关用户订阅的关系 /// 分页查询 /// </summary> /// <returns> /// IsSubscription = true 订阅 /// IsSubscription = false 为订阅 /// </returns> public async Task <IQueryable <SysNotificationSubscriptionInfo> > QueryableSubscriptionByNameAsync(SysUserNotificationInfo notificationInfo) { var list = from u in base.Context.UserInfos join n in base.Context.NotificationSubscriptionInfos on new { id = u.Id, nname = notificationInfo.NotificationName } equals new { id = n.UserId, nname = n.NotificationName } into br from un in br.DefaultIfEmpty() where u.UserNameCn.Contains(notificationInfo.UserNameCn) || u.UserCode.Contains(notificationInfo.UserNameCn) select new SysNotificationSubscriptionInfo { UserId = u.Id, UserCode = u.UserCode, UserNameCn = u.UserNameCn, ImageUrl = u.ImageUrl, TenantId = un.TenantId, EntityId = un.EntityId, EntityTypeAssemblyQualifiedName = un.EntityTypeAssemblyQualifiedName, EntityTypeName = un.EntityTypeName, NotificationName = un.NotificationName, IsSubscription = un.NotificationName == null ? false : true }; return(await Task.FromResult(list)); }