Browse Source

增加用户订阅相关api;创建nuget包

pull/7/head
cKey 6 years ago
parent
commit
73f8bf2d31
  1. 4
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationStore.cs
  2. 15
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationSubscriptionManager.cs
  3. 10
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Internal/NotificationSubscriptionManager.cs
  4. 7
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj
  5. 7
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN.Abp.MessageService.Domain.csproj
  6. 31
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs
  7. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/IUserSubscribeRepository.cs
  8. 8
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj
  9. 6
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs

4
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationStore.cs

@ -12,6 +12,10 @@ namespace LINGYUN.Abp.Notifications
Task DeleteUserSubscriptionAsync(Guid? tenantId, Guid userId, string notificationName); Task DeleteUserSubscriptionAsync(Guid? tenantId, Guid userId, string notificationName);
Task DeleteAllUserSubscriptionAsync(Guid? tenantId, string notificationName);
Task DeleteUserSubscriptionAsync(Guid? tenantId, IEnumerable<UserIdentifier> identifiers, string notificationName);
Task<List<NotificationSubscriptionInfo>> GetSubscriptionsAsync(Guid? tenantId, string notificationName); Task<List<NotificationSubscriptionInfo>> GetSubscriptionsAsync(Guid? tenantId, string notificationName);
Task<List<NotificationSubscriptionInfo>> GetUserSubscriptionsAsync(Guid? tenantId, Guid userId); Task<List<NotificationSubscriptionInfo>> GetUserSubscriptionsAsync(Guid? tenantId, Guid userId);

15
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationSubscriptionManager.cs

@ -34,6 +34,13 @@ namespace LINGYUN.Abp.Notifications
/// <returns></returns> /// <returns></returns>
Task SubscribeAsync(Guid? tenantId, IEnumerable<UserIdentifier> identifiers, string notificationName); Task SubscribeAsync(Guid? tenantId, IEnumerable<UserIdentifier> identifiers, string notificationName);
/// <summary> /// <summary>
/// 取消所有用户订阅
/// </summary>
/// <param name="tenantId">租户</param>
/// <param name="notificationName">通知名称</param>
/// <returns></returns>
Task UnsubscribeAllAsync(Guid? tenantId, string notificationName);
/// <summary>
/// 取消订阅 /// 取消订阅
/// </summary> /// </summary>
/// <param name="tenantId">租户</param> /// <param name="tenantId">租户</param>
@ -42,6 +49,14 @@ namespace LINGYUN.Abp.Notifications
/// <returns></returns> /// <returns></returns>
Task UnsubscribeAsync(Guid? tenantId, UserIdentifier identifier, string notificationName); Task UnsubscribeAsync(Guid? tenantId, UserIdentifier identifier, string notificationName);
/// <summary> /// <summary>
/// 取消订阅
/// </summary>
/// <param name="tenantId">租户</param>
/// <param name="identifiers">用户标识列表</param>
/// <param name="notificationName">通知名称</param>
/// <returns></returns>
Task UnsubscribeAsync(Guid? tenantId, IEnumerable<UserIdentifier> identifiers, string notificationName);
/// <summary>
/// 获取通知被订阅用户列表 /// 获取通知被订阅用户列表
/// </summary> /// </summary>
/// <param name="tenantId">租户</param> /// <param name="tenantId">租户</param>

10
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Internal/NotificationSubscriptionManager.cs

@ -56,5 +56,15 @@ namespace LINGYUN.Abp.Notifications.Internal
{ {
await _store.DeleteUserSubscriptionAsync(tenantId, identifier.UserId, notificationName); await _store.DeleteUserSubscriptionAsync(tenantId, identifier.UserId, notificationName);
} }
public virtual async Task UnsubscribeAllAsync(Guid? tenantId, string notificationName)
{
await _store.DeleteAllUserSubscriptionAsync(tenantId, notificationName);
}
public virtual async Task UnsubscribeAsync(Guid? tenantId, IEnumerable<UserIdentifier> identifiers, string notificationName)
{
await _store.DeleteUserSubscriptionAsync(tenantId, identifiers, notificationName);
}
} }
} }

7
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj

@ -3,6 +3,13 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace /> <RootNamespace />
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.9.0</Version>
<Authors>LINGYUN</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>D:\LocalNuget</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

7
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN.Abp.MessageService.Domain.csproj

@ -3,6 +3,13 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace /> <RootNamespace />
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.9.0</Version>
<Authors>LINGYUN</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>D:\LocalNuget</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

31
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs

@ -3,6 +3,7 @@ using LINGYUN.Abp.MessageService.Utils;
using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
using Volo.Abp.Json; using Volo.Abp.Json;
@ -77,6 +78,20 @@ namespace LINGYUN.Abp.MessageService.Notifications
} }
} }
[UnitOfWork]
public async Task DeleteAllUserSubscriptionAsync(Guid? tenantId, string notificationName)
{
using (var unitOfWork = _unitOfWorkManager.Begin())
using (CurrentTenant.Change(tenantId))
{
var userSubscribes = await UserSubscribeRepository.GetSubscribesAsync(notificationName);
await UserSubscribeRepository.DeleteUserSubscriptionAsync(userSubscribes);
await unitOfWork.SaveChangesAsync();
}
}
[UnitOfWork] [UnitOfWork]
public async Task DeleteUserSubscriptionAsync(Guid? tenantId, Guid userId, string notificationName) public async Task DeleteUserSubscriptionAsync(Guid? tenantId, Guid userId, string notificationName)
{ {
@ -90,6 +105,22 @@ namespace LINGYUN.Abp.MessageService.Notifications
} }
} }
[UnitOfWork]
public async Task DeleteUserSubscriptionAsync(Guid? tenantId, IEnumerable<UserIdentifier> identifiers, string notificationName)
{
using (var unitOfWork = _unitOfWorkManager.Begin())
using (CurrentTenant.Change(tenantId))
{
var userSubscribes = await UserSubscribeRepository.GetSubscribesAsync(notificationName);
var removeUserSubscribes = userSubscribes.Where(us => identifiers.Any(id => id.UserId.Equals(us.UserId)));
await UserSubscribeRepository.DeleteUserSubscriptionAsync(removeUserSubscribes);
await unitOfWork.SaveChangesAsync();
}
}
public async Task<NotificationInfo> GetNotificationOrNullAsync(Guid? tenantId, long notificationId) public async Task<NotificationInfo> GetNotificationOrNullAsync(Guid? tenantId, long notificationId)
{ {
using (CurrentTenant.Change(tenantId)) using (CurrentTenant.Change(tenantId))

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Subscriptions/IUserSubscribeRepository.cs

@ -20,5 +20,7 @@ namespace LINGYUN.Abp.MessageService.Subscriptions
Task<List<Guid>> GetUserSubscribesAsync(string notificationName); Task<List<Guid>> GetUserSubscribesAsync(string notificationName);
Task InsertUserSubscriptionAsync(IEnumerable<UserSubscribe> userSubscribes); Task InsertUserSubscriptionAsync(IEnumerable<UserSubscribe> userSubscribes);
Task DeleteUserSubscriptionAsync(IEnumerable<UserSubscribe> userSubscribes);
} }
} }

8
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj

@ -3,6 +3,14 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace /> <RootNamespace />
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.9.0</Version>
<Authors>LINGYUN</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>D:\LocalNuget</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

6
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs

@ -78,6 +78,12 @@ namespace LINGYUN.Abp.MessageService.Subscriptions
await DbSet.AddRangeAsync(userSubscribes); await DbSet.AddRangeAsync(userSubscribes);
} }
public Task DeleteUserSubscriptionAsync(IEnumerable<UserSubscribe> userSubscribes)
{
DbSet.RemoveRange(userSubscribes);
return Task.CompletedTask;
}
public async Task<bool> UserSubscribeExistsAysnc(string notificationName, Guid userId) public async Task<bool> UserSubscribeExistsAysnc(string notificationName, Guid userId)
{ {
return await DbSet.AnyAsync(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName)); return await DbSet.AnyAsync(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName));

Loading…
Cancel
Save