Browse Source

Remove some interfaces from the message repository

pull/145/head
cKey 5 years ago
parent
commit
fb9b5be234
  1. 7
      .vs/VSWorkspaceState.json
  2. BIN
      .vs/slnx.sqlite
  3. 29
      aspnet-core/LINGYUN.MicroService.Messages.sln
  4. 1
      aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LICENSE.txt
  5. 17
      aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/README.md
  6. 4
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationCleanupOptions.cs
  7. 6
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationStore.cs
  8. 11
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationStore.cs
  9. 19
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/README.md
  10. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByPagedDto.cs
  11. 11
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/AbpMessageServiceDomainModule.cs
  12. 14
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IUserNotificationRepository.cs
  13. 19
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs
  14. 109
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Utils/SnowflakeIdGenerator.cs
  15. 24
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Utils/SnowflakeIdOptions.cs
  16. 46
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs
  17. 5
      aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs
  18. 16
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Utils/SnowflakeIdGenerator.cs
  19. 23
      aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN.Abp.MessageService.Domain.Tests.csproj
  20. 36
      aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN/Abp/MessageService/AbpMessageServiceDomainTestModule.cs
  21. 75
      aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN/Abp/MessageService/AbpNotificationsTestsDataBuilder.cs
  22. 24
      aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj
  23. 8
      aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreTestBase.cs
  24. 15
      aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreTestModule.cs
  25. 81
      aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN/Abp/MessageService/Notifications/UserNotificationRepositoryTests.cs
  26. 1
      aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/AbpNotificationsTestsModule.cs
  27. 15
      aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestConsts.cs

7
.vs/VSWorkspaceState.json

@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\D:\\Projects\\MicroService\\CRM\\Vue\\vue-abp",
"PreviewInSolutionExplorer": false
}

BIN
.vs/slnx.sqlite

Binary file not shown.

29
aspnet-core/LINGYUN.MicroService.Messages.sln

@ -53,17 +53,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.MiniProg
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Sms", "modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj", "{454059F7-D087-439A-A724-80BDFE94776F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Sms", "modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj", "{454059F7-D087-439A-A724-80BDFE94776F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.WeChat.MiniProgram", "modules\wechat\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj", "{64E2622A-611D-4056-9497-0B52A91DC59C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.WeChat.MiniProgram", "modules\wechat\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj", "{64E2622A-611D-4056-9497-0B52A91DC59C}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{42800C56-9473-4B96-BF29-1B0F25C867F4}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{42800C56-9473-4B96-BF29-1B0F25C867F4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Sms.Tests", "tests\LINGYUN.Abp.Notifications.Sms.Tests\LINGYUN.Abp.Notifications.Sms.Tests.csproj", "{5714481A-BDF5-4860-9158-3B18D3018EC5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Sms.Tests", "tests\LINGYUN.Abp.Notifications.Sms.Tests\LINGYUN.Abp.Notifications.Sms.Tests.csproj", "{5714481A-BDF5-4860-9158-3B18D3018EC5}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TestsBase", "tests\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj", "{B5E23AED-3068-4CFE-84B0-3B7725665506}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TestsBase", "tests\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj", "{B5E23AED-3068-4CFE-84B0-3B7725665506}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Tests", "tests\LINGYUN.Abp.Notifications.Tests\LINGYUN.Abp.Notifications.Tests.csproj", "{E5257008-A0AD-473F-91B0-864FC601B84B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Tests", "tests\LINGYUN.Abp.Notifications.Tests\LINGYUN.Abp.Notifications.Tests.csproj", "{E5257008-A0AD-473F-91B0-864FC601B84B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests", "tests\LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests\LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj", "{DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests", "tests\LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests\LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests.csproj", "{DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.EntityFrameworkCore.Tests", "tests\LINGYUN.Abp.EntityFrameworkCore.Tests\LINGYUN.Abp.EntityFrameworkCore.Tests.csproj", "{25267137-08BE-44A6-9F7E-7783CC8C62E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests", "tests\LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests\LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj", "{CB6D56DA-539B-4D4F-81CD-D683ADEBFB5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.MessageService.Domain.Tests", "tests\LINGYUN.Abp.MessageService.Domain.Tests\LINGYUN.Abp.MessageService.Domain.Tests.csproj", "{097319B9-D062-4A54-8F8C-001C180E2CB3}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -171,6 +177,18 @@ Global
{DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}.Release|Any CPU.Build.0 = Release|Any CPU {DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7}.Release|Any CPU.Build.0 = Release|Any CPU
{25267137-08BE-44A6-9F7E-7783CC8C62E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25267137-08BE-44A6-9F7E-7783CC8C62E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25267137-08BE-44A6-9F7E-7783CC8C62E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25267137-08BE-44A6-9F7E-7783CC8C62E8}.Release|Any CPU.Build.0 = Release|Any CPU
{CB6D56DA-539B-4D4F-81CD-D683ADEBFB5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB6D56DA-539B-4D4F-81CD-D683ADEBFB5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB6D56DA-539B-4D4F-81CD-D683ADEBFB5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB6D56DA-539B-4D4F-81CD-D683ADEBFB5F}.Release|Any CPU.Build.0 = Release|Any CPU
{097319B9-D062-4A54-8F8C-001C180E2CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{097319B9-D062-4A54-8F8C-001C180E2CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{097319B9-D062-4A54-8F8C-001C180E2CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{097319B9-D062-4A54-8F8C-001C180E2CB3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -204,6 +222,9 @@ Global
{B5E23AED-3068-4CFE-84B0-3B7725665506} = {42800C56-9473-4B96-BF29-1B0F25C867F4} {B5E23AED-3068-4CFE-84B0-3B7725665506} = {42800C56-9473-4B96-BF29-1B0F25C867F4}
{E5257008-A0AD-473F-91B0-864FC601B84B} = {42800C56-9473-4B96-BF29-1B0F25C867F4} {E5257008-A0AD-473F-91B0-864FC601B84B} = {42800C56-9473-4B96-BF29-1B0F25C867F4}
{DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7} = {42800C56-9473-4B96-BF29-1B0F25C867F4} {DB425943-CEE6-4FF6-A0EE-233B6ADA3BD7} = {42800C56-9473-4B96-BF29-1B0F25C867F4}
{25267137-08BE-44A6-9F7E-7783CC8C62E8} = {42800C56-9473-4B96-BF29-1B0F25C867F4}
{CB6D56DA-539B-4D4F-81CD-D683ADEBFB5F} = {42800C56-9473-4B96-BF29-1B0F25C867F4}
{097319B9-D062-4A54-8F8C-001C180E2CB3} = {42800C56-9473-4B96-BF29-1B0F25C867F4}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6238659A-7267-49B9-A499-8746BDEED6B8} SolutionGuid = {6238659A-7267-49B9-A499-8746BDEED6B8}

1
aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LICENSE.txt

@ -21,4 +21,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
模块来源 模块来源
https://github.com/dotnetcore/CAP
https://github.com/EasyAbp/Abp.EventBus.CAP https://github.com/EasyAbp/Abp.EventBus.CAP

17
aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/README.md

@ -0,0 +1,17 @@
# LINGYUN.Abp.EventBus.CAP
分布式事件总线 CAP 集成
#### 注意
* 由于 CAP 官方模块中, MySqlConnector 为高版本,与 Volo.Abp.EntityFrameworkCore.MySQL 依赖版本不兼容
当 Abp 框架升级到 4.0 版本之后,此模块升级为 CAP 最新版本
## 配置使用
```csharp
[DependsOn(typeof(AbpCAPEventBusModule))]
public class YouProjectModule : AbpModule
{
// other
}

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

@ -9,9 +9,9 @@
public bool IsEnabled { get; set; } = true; public bool IsEnabled { get; set; } = true;
/// <summary> /// <summary>
/// 清理时间间隔 /// 清理时间间隔
/// 默认:300000ms /// 默认:30_0000ms
/// </summary> /// </summary>
public int CleanupPeriod { get; set; } = 300000; public int CleanupPeriod { get; set; } = 30_0000;
/// <summary> /// <summary>
/// 清理批次 /// 清理批次
/// 默认: 200 /// 默认: 200

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

@ -94,7 +94,7 @@ namespace LINGYUN.Abp.Notifications
Task<List<NotificationInfo>> GetUserNotificationsAsync( Task<List<NotificationInfo>> GetUserNotificationsAsync(
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
@ -102,7 +102,7 @@ namespace LINGYUN.Abp.Notifications
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
string filter = "", string filter = "",
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<NotificationInfo>> GetUserNotificationsAsync( Task<List<NotificationInfo>> GetUserNotificationsAsync(
@ -111,7 +111,7 @@ namespace LINGYUN.Abp.Notifications
string filter = "", string filter = "",
string sorting = nameof(NotificationInfo.CreationTime), string sorting = nameof(NotificationInfo.CreationTime),
bool reverse = true, bool reverse = true,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int skipCount = 1, int skipCount = 1,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);

11
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationStore.cs

@ -6,9 +6,8 @@ using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.Notifications namespace LINGYUN.Abp.Notifications
{ {
[Dependency(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton, TryRegister = true)] [Dependency(TryRegister = true)]
[ExposeServices(typeof(INotificationStore))] public class NullNotificationStore : INotificationStore, ISingletonDependency
public class NullNotificationStore : INotificationStore
{ {
public Task ChangeUserNotificationReadStateAsync( public Task ChangeUserNotificationReadStateAsync(
Guid? tenantId, Guid? tenantId,
@ -89,7 +88,7 @@ namespace LINGYUN.Abp.Notifications
public Task<List<NotificationInfo>> GetUserNotificationsAsync( public Task<List<NotificationInfo>> GetUserNotificationsAsync(
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -100,7 +99,7 @@ namespace LINGYUN.Abp.Notifications
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
string filter = "", string filter = "",
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return Task.FromResult(0); return Task.FromResult(0);
@ -112,7 +111,7 @@ namespace LINGYUN.Abp.Notifications
string filter = "", string filter = "",
string sorting = nameof(NotificationInfo.CreationTime), string sorting = nameof(NotificationInfo.CreationTime),
bool reverse = true, bool reverse = true,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int skipCount = 1, int skipCount = 1,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)

19
aspnet-core/modules/common/LINGYUN.Abp.Notifications/README.md

@ -0,0 +1,19 @@
# LINGYUN.Abp.Notifications
实时通知基础模块
#### 注意
* 当前的通知数据模型 NotificationData 设计极度不合理
将在框架升级为4.0版本之后变更,将与现有通知数据不兼容(这可能就是敏捷开发的避免吧 ;) )
## 配置使用
```csharp
[DependsOn(typeof(AbpNotificationModule))]
public class YouProjectModule : AbpModule
{
// other
}

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/UserNotificationGetByPagedDto.cs

@ -9,6 +9,6 @@ namespace LINGYUN.Abp.MessageService.Notifications
public bool Reverse { get; set; } public bool Reverse { get; set; }
public NotificationReadState ReadState { get; set; } = NotificationReadState.Read; public NotificationReadState? ReadState { get; set; }
} }
} }

11
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/AbpMessageServiceDomainModule.cs

@ -2,6 +2,9 @@
using LINGYUN.Abp.MessageService.Localization; using LINGYUN.Abp.MessageService.Localization;
using LINGYUN.Abp.MessageService.Mapper; using LINGYUN.Abp.MessageService.Mapper;
using LINGYUN.Abp.MessageService.ObjectExtending; using LINGYUN.Abp.MessageService.ObjectExtending;
using LINGYUN.Abp.MessageService.Utils;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Localization; using Volo.Abp.Localization;
@ -51,5 +54,13 @@ namespace LINGYUN.Abp.MessageService
typeof(Message) typeof(Message)
); );
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
context
.ServiceProvider
.GetRequiredService<SnowflakeIdGenerator>()
.Initialize();
}
} }
} }

14
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/IUserNotificationRepository.cs

@ -25,14 +25,14 @@ namespace LINGYUN.Abp.MessageService.Notifications
Task<List<Notification>> GetNotificationsAsync( Task<List<Notification>> GetNotificationsAsync(
Guid userId, Guid userId,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<int> GetCountAsync( Task<int> GetCountAsync(
Guid userId, Guid userId,
string filter = "", string filter = "",
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Notification>> GetListAsync( Task<List<Notification>> GetListAsync(
@ -40,15 +40,9 @@ namespace LINGYUN.Abp.MessageService.Notifications
string filter = "", string filter = "",
string sorting = nameof(Notification.CreationTime), string sorting = nameof(Notification.CreationTime),
bool reverse = true, bool reverse = true,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int skipCount = 1, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task ChangeUserNotificationReadStateAsync(
Guid userId,
long notificationId,
NotificationReadState readState,
CancellationToken cancellationToken = default);
} }
} }

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

@ -1,6 +1,7 @@
using LINGYUN.Abp.MessageService.Subscriptions; using LINGYUN.Abp.MessageService.Subscriptions;
using LINGYUN.Abp.MessageService.Utils; using LINGYUN.Abp.MessageService.Utils;
using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications;
using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,7 +16,9 @@ using Volo.Abp.Uow;
namespace LINGYUN.Abp.MessageService.Notifications namespace LINGYUN.Abp.MessageService.Notifications
{ {
public class NotificationStore : INotificationStore, ITransientDependency [Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
[ExposeServices(typeof(INotificationStore))]
public class NotificationStore : INotificationStore
{ {
private readonly IClock _clock; private readonly IClock _clock;
@ -68,12 +71,16 @@ namespace LINGYUN.Abp.MessageService.Notifications
using (var unitOfWork = _unitOfWorkManager.Begin()) using (var unitOfWork = _unitOfWorkManager.Begin())
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
{ {
await _userNotificationRepository var notification = await _userNotificationRepository.GetByIdAsync(userId, notificationId);
.ChangeUserNotificationReadStateAsync(userId, notificationId, readState, cancellationToken); if (notification != null)
{
notification.ChangeReadState(readState);
await _userNotificationRepository.UpdateAsync(notification);
await unitOfWork.SaveChangesAsync(); await unitOfWork.SaveChangesAsync();
} }
} }
}
public virtual async Task DeleteNotificationAsync( public virtual async Task DeleteNotificationAsync(
NotificationInfo notification, NotificationInfo notification,
@ -213,7 +220,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
public virtual async Task<List<NotificationInfo>> GetUserNotificationsAsync( public virtual async Task<List<NotificationInfo>> GetUserNotificationsAsync(
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -230,7 +237,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
string filter = "", string filter = "",
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
@ -246,7 +253,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
string filter = "", string filter = "",
string sorting = nameof(NotificationInfo.CreationTime), string sorting = nameof(NotificationInfo.CreationTime),
bool reverse = true, bool reverse = true,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int skipCount = 1, int skipCount = 1,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)

109
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Utils/SnowflakeIdGenerator.cs

@ -0,0 +1,109 @@
using Microsoft.Extensions.Options;
using System;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.MessageService.Utils
{
// reference: https://github.com/dotnetcore/CAP
// reference: https://blog.csdn.net/lq18050010830/article/details/89845790
public class SnowflakeIdGenerator : ISnowflakeIdGenerator, ISingletonDependency
{
public const long Twepoch = 1288834974657L;
private static readonly object _lock = new object();
private long _lastTimestamp = -1L;
protected long MaxWorkerId { get; set; }
protected long MaxDatacenterId { get; set; }
protected int WorkerIdShift { get; }
protected int DatacenterIdShift { get; }
protected int TimestampLeftShift { get; }
protected long SequenceMask { get; }
protected SnowflakeIdOptions Options { get; }
public SnowflakeIdGenerator(IOptions<SnowflakeIdOptions> options)
{
Options = options.Value;
WorkerIdShift = Options.SequenceBits;
DatacenterIdShift = Options.SequenceBits + Options.WorkerIdBits;
TimestampLeftShift = Options.SequenceBits + Options.WorkerIdBits + Options.DatacenterIdBits;
SequenceMask = -1L ^ (-1L << Options.SequenceBits);
}
internal void Initialize(long sequence = 0L)
{
Sequence = sequence;
MaxWorkerId = -1L ^ (-1L << Options.WorkerIdBits);
MaxDatacenterId = -1L ^ (-1L << Options.DatacenterIdBits);
if (!int.TryParse(Environment.GetEnvironmentVariable("WORKERID", EnvironmentVariableTarget.Machine), out var workerId))
{
workerId = RandomHelper.GetRandom((int)MaxWorkerId);
}
if (!int.TryParse(Environment.GetEnvironmentVariable("DATACENTERID", EnvironmentVariableTarget.Machine), out var datacenterId))
{
datacenterId = RandomHelper.GetRandom((int)MaxDatacenterId);
}
if (workerId > MaxWorkerId || workerId < 0)
throw new ArgumentException($"worker Id can't be greater than {MaxWorkerId} or less than 0");
if (datacenterId > MaxDatacenterId || datacenterId < 0)
throw new ArgumentException($"datacenter Id can't be greater than {MaxDatacenterId} or less than 0");
WorkerId = workerId;
DatacenterId = datacenterId;
}
public long WorkerId { get; protected set; }
public long DatacenterId { get; protected set; }
public long Sequence { get; protected set; }
public virtual long Create()
{
lock (_lock)
{
var timestamp = TimeGen();
if (timestamp < _lastTimestamp)
throw new Exception(
$"InvalidSystemClock: Clock moved backwards, Refusing to generate id for {_lastTimestamp - timestamp} milliseconds");
if (_lastTimestamp == timestamp)
{
Sequence = (Sequence + 1) & SequenceMask;
if (Sequence == 0) timestamp = TilNextMillis(_lastTimestamp);
}
else
{
Sequence = 0;
}
_lastTimestamp = timestamp;
var id = ((timestamp - Twepoch) << TimestampLeftShift) |
(DatacenterId << DatacenterIdShift) |
(WorkerId << WorkerIdShift) | Sequence;
return id;
}
}
protected virtual long TilNextMillis(long lastTimestamp)
{
var timestamp = TimeGen();
while (timestamp <= lastTimestamp) timestamp = TimeGen();
return timestamp;
}
protected virtual long TimeGen()
{
return DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
}
}

24
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Utils/SnowflakeIdOptions.cs

@ -0,0 +1,24 @@
namespace LINGYUN.Abp.MessageService.Utils
{
public class SnowflakeIdOptions
{
/// <summary>
/// 机器Id长度
/// </summary>
public int WorkerIdBits { get; set; }
/// <summary>
/// 机房Id长度
/// </summary>
public int DatacenterIdBits { get; set; }
/// <summary>
/// 每秒生成Id的数量
/// </summary>
public int SequenceBits { get; set; }
public SnowflakeIdOptions()
{
WorkerIdBits = 5;
DatacenterIdBits = 5;
SequenceBits = 12;
}
}
}

46
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs

@ -39,18 +39,6 @@ namespace LINGYUN.Abp.MessageService.Notifications
await DbSet.AddRangeAsync(userNotifications, GetCancellationToken(cancellationToken)); await DbSet.AddRangeAsync(userNotifications, GetCancellationToken(cancellationToken));
} }
public virtual async Task ChangeUserNotificationReadStateAsync(
Guid userId,
long notificationId,
NotificationReadState readState,
CancellationToken cancellationToken = default)
{
var userNofitication = await GetByIdAsync(userId, notificationId, cancellationToken);
userNofitication.ChangeReadState(readState);
DbSet.Update(userNofitication);
}
public virtual async Task<UserNotification> GetByIdAsync( public virtual async Task<UserNotification> GetByIdAsync(
Guid userId, Guid userId,
long notificationId, long notificationId,
@ -65,17 +53,20 @@ namespace LINGYUN.Abp.MessageService.Notifications
public virtual async Task<List<Notification>> GetNotificationsAsync( public virtual async Task<List<Notification>> GetNotificationsAsync(
Guid userId, Guid userId,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var userNotifilerQuery = from un in DbContext.Set<UserNotification>() var userNotifilerQuery = DbContext.Set<UserNotification>()
.Where(x => x.UserId == userId)
.WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value);
var notifilerQuery = from un in userNotifilerQuery
join n in DbContext.Set<Notification>() join n in DbContext.Set<Notification>()
on un.NotificationId equals n.NotificationId on un.NotificationId equals n.NotificationId
where un.UserId.Equals(userId) && un.ReadStatus.Equals(readState)
select n; select n;
return await userNotifilerQuery return await notifilerQuery
.OrderBy(nameof(Notification.CreationTime) + " DESC") .OrderBy(nameof(Notification.CreationTime) + " DESC")
.Take(maxResultCount) .Take(maxResultCount)
.AsNoTracking() .AsNoTracking()
@ -85,16 +76,19 @@ namespace LINGYUN.Abp.MessageService.Notifications
public virtual async Task<int> GetCountAsync( public virtual async Task<int> GetCountAsync(
Guid userId, Guid userId,
string filter = "", string filter = "",
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var userNotifilerQuery = from un in DbContext.Set<UserNotification>() var userNotifilerQuery = DbContext.Set<UserNotification>()
.Where(x => x.UserId == userId)
.WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value);
var notifilerQuery = from un in userNotifilerQuery
join n in DbContext.Set<Notification>() join n in DbContext.Set<Notification>()
on un.NotificationId equals n.NotificationId on un.NotificationId equals n.NotificationId
where un.UserId.Equals(userId) && un.ReadStatus.Equals(readState)
select n; select n;
return await userNotifilerQuery return await notifilerQuery
.WhereIf(!filter.IsNullOrWhiteSpace(), nf => .WhereIf(!filter.IsNullOrWhiteSpace(), nf =>
nf.NotificationName.Contains(filter) || nf.NotificationName.Contains(filter) ||
nf.NotificationTypeName.Contains(filter)) nf.NotificationTypeName.Contains(filter))
@ -106,7 +100,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
string filter = "", string filter = "",
string sorting = nameof(Notification.CreationTime), string sorting = nameof(Notification.CreationTime),
bool reverse = true, bool reverse = true,
NotificationReadState readState = NotificationReadState.UnRead, NotificationReadState? readState = null,
int skipCount = 1, int skipCount = 1,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -114,13 +108,17 @@ namespace LINGYUN.Abp.MessageService.Notifications
sorting ??= nameof(Notification.CreationTime); sorting ??= nameof(Notification.CreationTime);
sorting = reverse ? sorting + " DESC" : sorting; sorting = reverse ? sorting + " DESC" : sorting;
var userNotifilerQuery = from un in DbContext.Set<UserNotification>()
var userNotifilerQuery = DbContext.Set<UserNotification>()
.Where(x => x.UserId == userId)
.WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value);
var notifilerQuery = from un in userNotifilerQuery
join n in DbContext.Set<Notification>() join n in DbContext.Set<Notification>()
on un.NotificationId equals n.NotificationId on un.NotificationId equals n.NotificationId
where un.UserId.Equals(userId) && un.ReadStatus.Equals(readState)
select n; select n;
return await userNotifilerQuery return await notifilerQuery
.WhereIf(!filter.IsNullOrWhiteSpace(), nf => .WhereIf(!filter.IsNullOrWhiteSpace(), nf =>
nf.NotificationName.Contains(filter) || nf.NotificationName.Contains(filter) ||
nf.NotificationTypeName.Contains(filter)) nf.NotificationTypeName.Contains(filter))

5
aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs

@ -349,10 +349,11 @@ namespace LINGYUN.Abp.BackendAdmin
// 路由 // 路由
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();
// 调试代理连接信息用,上线后注释掉
app.UseProxyConnectTest();
if (context.GetEnvironment().IsDevelopment()) if (context.GetEnvironment().IsDevelopment())
{ {
// 开发模式下调试代理连接信息用
app.UseProxyConnectTest();
SeedData(context); SeedData(context);
} }
} }

16
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Utils/SnowflakeIdGenerator.cs

@ -1,16 +0,0 @@
using DotNetCore.CAP.Internal;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.MessageService.Utils
{
[Dependency(ServiceLifetime.Singleton, TryRegister = true)]
[ExposeServices(typeof(ISnowflakeIdGenerator))]
public class SnowflakeIdGenerator : ISnowflakeIdGenerator
{
public long Create()
{
return SnowflakeId.Default().NextId();
}
}
}

23
aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN.Abp.MessageService.Domain.Tests.csproj

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace />
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\message\LINGYUN.Abp.MessageService.Domain\LINGYUN.Abp.MessageService.Domain.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Notifications.Tests\LINGYUN.Abp.Notifications.Tests.csproj" />
</ItemGroup>
</Project>

36
aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN/Abp/MessageService/AbpMessageServiceDomainTestModule.cs

@ -0,0 +1,36 @@
using LINGYUN.Abp.Notifications;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace LINGYUN.Abp.MessageService
{
[DependsOn(
typeof(AbpMessageServiceDomainModule),
typeof(AbpNotificationsTestsModule)
)]
public class AbpMessageServiceDomainTestModule : AbpModule
{
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
SeedTestData(context);
}
private static void SeedTestData(ApplicationInitializationContext context)
{
using (var scope = context.ServiceProvider.CreateScope())
{
var dataSeeder = scope.ServiceProvider.GetRequiredService<IDataSeeder>();
AsyncHelper.RunSync(async () =>
{
await dataSeeder.SeedAsync();
await scope.ServiceProvider
.GetRequiredService<AbpNotificationsTestDataBuilder>()
.BuildAsync();
});
}
}
}
}

75
aspnet-core/tests/LINGYUN.Abp.MessageService.Domain.Tests/LINGYUN/Abp/MessageService/AbpNotificationsTestsDataBuilder.cs

@ -0,0 +1,75 @@
using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.Notifications;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.MessageService
{
public class AbpNotificationsTestDataBuilder : ITransientDependency
{
private readonly INotificationStore _notificationStore;
private readonly IUserNotificationRepository _userNotificationRepository;
public AbpNotificationsTestDataBuilder(
INotificationStore notificationStore,
IUserNotificationRepository userNotificationRepository)
{
_notificationStore = notificationStore;
_userNotificationRepository = userNotificationRepository;
}
public async Task BuildAsync()
{
await AddNotificationsAsync();
}
private async Task AddUserNotificationsAsync(NotificationInfo notificationInfo, IEnumerable<Guid> userIds)
{
await _notificationStore.InsertUserNotificationsAsync(notificationInfo, userIds);
}
private async Task AddNotificationsAsync()
{
var notification1 = new NotificationInfo
{
Name = NotificationsTestsNames.Test1,
Severity = NotificationSeverity.Success,
CreationTime = DateTime.Now,
Lifetime = NotificationLifetime.OnlyOne,
Type = NotificationType.Application
};
var notification2 = new NotificationInfo
{
Name = NotificationsTestsNames.Test2,
Severity = NotificationSeverity.Success,
CreationTime = DateTime.Now,
Lifetime = NotificationLifetime.Persistent,
Type = NotificationType.Application
};
var notification3 = new NotificationInfo
{
Name = NotificationsTestsNames.Test3,
Severity = NotificationSeverity.Success,
CreationTime = DateTime.Now,
Lifetime = NotificationLifetime.OnlyOne,
Type = NotificationType.User
};
await _notificationStore.InsertNotificationAsync(notification1);
await _notificationStore.InsertNotificationAsync(notification2);
await _notificationStore.InsertNotificationAsync(notification3);
NotificationsTestConsts.NotificationId1 = notification1.GetId();
NotificationsTestConsts.NotificationId2 = notification2.GetId();
NotificationsTestConsts.NotificationId3 = notification3.GetId();
await AddUserNotificationsAsync(notification2, new Guid[] { NotificationsTestConsts.User1Id, NotificationsTestConsts.User2Id });
await AddUserNotificationsAsync(notification3, new Guid[] { NotificationsTestConsts.User1Id });
await _notificationStore.ChangeUserNotificationReadStateAsync(null, NotificationsTestConsts.User1Id, NotificationsTestConsts.NotificationId3, NotificationReadState.Read);
}
}
}

24
aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests.csproj

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace />
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\message\LINGYUN.Abp.MessageService.EntityFrameworkCore\LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.EntityFrameworkCore.Tests\LINGYUN.Abp.EntityFrameworkCore.Tests.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.MessageService.Domain.Tests\LINGYUN.Abp.MessageService.Domain.Tests.csproj" />
</ItemGroup>
</Project>

8
aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreTestBase.cs

@ -0,0 +1,8 @@
using LINGYUN.Abp.Tests;
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
{
public abstract class AbpMessageServiceEntityFrameworkCoreTestBase : AbpTestsBase<AbpMessageServiceEntityFrameworkCoreTestModule>
{
}
}

15
aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreTestModule.cs

@ -0,0 +1,15 @@
using LINGYUN.Abp.EntityFrameworkCore.Tests;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
{
[DependsOn(
typeof(AbpMessageServiceEntityFrameworkCoreModule),
typeof(AbpMessageServiceDomainTestModule),
typeof(AbpEntityFrameworkCoreTestModule)
)]
public class AbpMessageServiceEntityFrameworkCoreTestModule : AbpModule
{
}
}

81
aspnet-core/tests/LINGYUN.Abp.MessageService.EntityFrameworkCore.Tests/LINGYUN/Abp/MessageService/Notifications/UserNotificationRepositoryTests.cs

@ -0,0 +1,81 @@
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.Notifications;
using Shouldly;
using System.Threading.Tasks;
using Xunit;
namespace LINGYUN.Abp.MessageService.Notifications
{
public class UserNotificationRepositoryTests : AbpMessageServiceEntityFrameworkCoreTestBase
{
private readonly IUserNotificationRepository _repository;
public UserNotificationRepositoryTests()
{
_repository = GetRequiredService<IUserNotificationRepository>();
}
[Fact]
public async Task AnyAsync_Test()
{
(await _repository.AnyAsync(NotificationsTestConsts.User1Id, NotificationsTestConsts.NotificationId1)).ShouldBeFalse();
(await _repository.AnyAsync(NotificationsTestConsts.User1Id, NotificationsTestConsts.NotificationId3)).ShouldBeTrue();
}
[Fact]
public async Task GetByIdAsync_Test()
{
(await _repository.GetByIdAsync(NotificationsTestConsts.User1Id, NotificationsTestConsts.NotificationId2)).ShouldNotBeNull();
(await _repository.GetByIdAsync(NotificationsTestConsts.User1Id, NotificationsTestConsts.NotificationId1)).ShouldBeNull();
}
[Fact]
public async Task GetNotificationsAsync_Test()
{
(await _repository.GetNotificationsAsync(
NotificationsTestConsts.User1Id,
NotificationReadState.Read))
.Count
.ShouldBe(1);
(await _repository.GetNotificationsAsync(
NotificationsTestConsts.User1Id,
NotificationReadState.UnRead))
.Count
.ShouldBe(1);
(await _repository.GetNotificationsAsync(
NotificationsTestConsts.User1Id))
.Count
.ShouldBe(2);
(await _repository.GetNotificationsAsync(
NotificationsTestConsts.User2Id,
NotificationReadState.UnRead))
.Count
.ShouldBe(1);
}
[Fact]
public async Task GetCountAsync_Test()
{
(await _repository.GetCountAsync(
NotificationsTestConsts.User1Id,
readState: NotificationReadState.Read))
.ShouldBe(1);
(await _repository.GetCountAsync(
NotificationsTestConsts.User1Id))
.ShouldBe(2);
}
[Fact]
public async Task GetListAsync_Test()
{
(await _repository.GetListAsync(
NotificationsTestConsts.User1Id,
readState: NotificationReadState.Read))
.Count
.ShouldBe(1);
(await _repository.GetListAsync(
NotificationsTestConsts.User1Id))
.Count
.ShouldBe(2);
}
}
}

1
aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/AbpNotificationsTestsModule.cs

@ -8,6 +8,5 @@ namespace LINGYUN.Abp.Notifications
typeof(AbpTestsBaseModule))] typeof(AbpTestsBaseModule))]
public class AbpNotificationsTestsModule : AbpModule public class AbpNotificationsTestsModule : AbpModule
{ {
} }
} }

15
aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestConsts.cs

@ -0,0 +1,15 @@
using System;
namespace LINGYUN.Abp.Notifications
{
public static class NotificationsTestConsts
{
public static Guid User1Id { get; } = Guid.NewGuid();
public static Guid User2Id { get; } = Guid.NewGuid();
public static long NotificationId1 { get; set; }
public static long NotificationId2 { get; set; }
public static long NotificationId3 { get; set; }
}
}
Loading…
Cancel
Save