From 11ca6efa33fda77875b3871aeb6fcb155c00b9d4 Mon Sep 17 00:00:00 2001
From: cKey <35512826+colinin@users.noreply.github.com>
Date: Mon, 28 Mar 2022 10:33:18 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=80=82=E7=94=A8?=
=?UTF-8?q?=E4=BA=8Eidentity=E6=A8=A1=E5=9D=97=E7=9A=84webhooks.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FodyWeavers.xml | 3 +
.../FodyWeavers.xsd | 30 +++++++++
.../LINGYUN.Abp.Webhooks.Identity.csproj | 30 +++++++++
.../Identity/AbpWebhooksIdentityModule.cs | 32 ++++++++++
.../Identity/IdentityRoleNameChangedWto.cs | 12 ++++
.../Identity/IdentityRoleWebHooker.cs | 62 +++++++++++++++++++
.../Abp/Webhooks/Identity/IdentityRoleWto.cs | 10 +++
.../Identity/IdentityUserWebHooker.cs | 55 ++++++++++++++++
.../Abp/Webhooks/Identity/IdentityUserWto.cs | 22 +++++++
.../IdentityWebhookDefinitionProvider.cs | 60 ++++++++++++++++++
.../Webhooks/Identity/IdentityWebhookNames.cs | 22 +++++++
.../Identity/Localization/Resources/en.json | 19 ++++++
.../Localization/Resources/zh-Hans.json | 19 ++++++
.../Identity/OrganizationUnitWebHooker.cs | 49 +++++++++++++++
.../Webhooks/Identity/OrganizationUnitWto.cs | 12 ++++
.../Webhooks/WebhooksNames.cs | 2 +-
...ice.WebhooksManagement.HttpApi.Host.csproj | 1 +
.../WebhooksManagementHttpApiHostModule.cs | 2 +
18 files changed, 441 insertions(+), 1 deletion(-)
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xml
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xsd
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN.Abp.Webhooks.Identity.csproj
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/AbpWebhooksIdentityModule.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleNameChangedWto.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWebHooker.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWto.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWebHooker.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWto.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookDefinitionProvider.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookNames.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/en.json
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/zh-Hans.json
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWebHooker.cs
create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWto.cs
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xml b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xml
new file mode 100644
index 000000000..ac6b5b292
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xsd b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xsd
new file mode 100644
index 000000000..11da52550
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/FodyWeavers.xsd
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
+
+
+
+
+ A comma-separated list of error codes that can be safely ignored in assembly verification.
+
+
+
+
+ 'false' to turn off automatic generation of the XML Schema file.
+
+
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN.Abp.Webhooks.Identity.csproj b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN.Abp.Webhooks.Identity.csproj
new file mode 100644
index 000000000..32c987515
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN.Abp.Webhooks.Identity.csproj
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/AbpWebhooksIdentityModule.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/AbpWebhooksIdentityModule.cs
new file mode 100644
index 000000000..0ca523251
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/AbpWebhooksIdentityModule.cs
@@ -0,0 +1,32 @@
+using Volo.Abp.Domain;
+using Volo.Abp.EventBus;
+using Volo.Abp.Identity;
+using Volo.Abp.Identity.Localization;
+using Volo.Abp.Localization;
+using Volo.Abp.Modularity;
+using Volo.Abp.Users;
+using Volo.Abp.VirtualFileSystem;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+[DependsOn(typeof(AbpDddDomainModule))]
+[DependsOn(typeof(AbpEventBusModule))]
+[DependsOn(typeof(AbpUsersAbstractionModule))]
+[DependsOn(typeof(AbpIdentityDomainSharedModule))]
+public class AbpWebhooksIdentityModule : AbpModule
+{
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.FileSets.AddEmbedded();
+ });
+
+ Configure(options =>
+ {
+ options.Resources
+ .Get()
+ .AddVirtualJson("/LINGYUN/Abp/Webhooks/Identity/Localization/Resources");
+ });
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleNameChangedWto.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleNameChangedWto.cs
new file mode 100644
index 000000000..5f55b78cf
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleNameChangedWto.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class IdentityRoleNameChangedWto
+{
+ public Guid Id { get; set; }
+
+ public string Name { get; set; }
+
+ public string OldName { get; set; }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWebHooker.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWebHooker.cs
new file mode 100644
index 000000000..ee1fdaee6
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWebHooker.cs
@@ -0,0 +1,62 @@
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Entities.Events.Distributed;
+using Volo.Abp.EventBus.Distributed;
+using Volo.Abp.Identity;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class IdentityRoleWebHooker :
+ IDistributedEventHandler>,
+ IDistributedEventHandler>,
+ IDistributedEventHandler,
+ ITransientDependency
+{
+ private readonly IWebhookPublisher _webhookPublisher;
+
+ public IdentityRoleWebHooker(
+ IWebhookPublisher webhookPublisher)
+ {
+ _webhookPublisher = webhookPublisher;
+ }
+
+ public async virtual Task HandleEventAsync(EntityCreatedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityRole.Create, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(EntityUpdatedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityRole.Update, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(EntityDeletedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityRole.Delete, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(IdentityRoleNameChangedEto eventData)
+ {
+ await _webhookPublisher.PublishAsync(
+ IdentityWebhookNames.IdentityRole.ChangeName,
+ new IdentityRoleNameChangedWto
+ {
+ Id = eventData.Id,
+ Name = eventData.Name,
+ OldName = eventData.OldName,
+ },
+ eventData.TenantId);
+ }
+
+ protected async virtual Task PublishAsync(string webhookName, IdentityRoleEto eto)
+ {
+ await _webhookPublisher.PublishAsync(
+ webhookName,
+ new IdentityRoleWto
+ {
+ Id = eto.Id,
+ Name = eto.Name
+ },
+ eto.TenantId);
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWto.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWto.cs
new file mode 100644
index 000000000..123a9f2dc
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityRoleWto.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class IdentityRoleWto
+{
+ public Guid Id { get; set; }
+
+ public string Name { get; set; }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWebHooker.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWebHooker.cs
new file mode 100644
index 000000000..fc48c2cab
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWebHooker.cs
@@ -0,0 +1,55 @@
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Entities.Events.Distributed;
+using Volo.Abp.EventBus.Distributed;
+using Volo.Abp.Users;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class IdentityUserWebHooker :
+ IDistributedEventHandler>,
+ IDistributedEventHandler>,
+ IDistributedEventHandler>,
+ ITransientDependency
+{
+ private readonly IWebhookPublisher _webhookPublisher;
+
+ public IdentityUserWebHooker(
+ IWebhookPublisher webhookPublisher)
+ {
+ _webhookPublisher = webhookPublisher;
+ }
+
+ public async virtual Task HandleEventAsync(EntityCreatedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityUser.Create, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(EntityUpdatedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityUser.Update, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(EntityDeletedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityUser.Delete, eventData.Entity);
+ }
+
+ protected async virtual Task PublishAsync(string webhookName, UserEto eto)
+ {
+ await _webhookPublisher.PublishAsync(
+ webhookName,
+ new IdentityUserWto
+ {
+ Id = eto.Id,
+ Name = eto.Name,
+ Email = eto.Email,
+ EmailConfirmed = eto.EmailConfirmed,
+ UserName = eto.UserName,
+ PhoneNumber = eto.PhoneNumber,
+ PhoneNumberConfirmed = eto.PhoneNumberConfirmed,
+ Surname = eto.Surname,
+ },
+ eto.TenantId);
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWto.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWto.cs
new file mode 100644
index 000000000..e5bf48665
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityUserWto.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class IdentityUserWto
+{
+ public Guid Id { get; set; }
+
+ public string UserName { get; set; }
+
+ public string Name { get; set; }
+
+ public string Surname { get; set; }
+
+ public string Email { get; set; }
+
+ public bool EmailConfirmed { get; set; }
+
+ public string PhoneNumber { get; set; }
+
+ public bool PhoneNumberConfirmed { get; set; }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookDefinitionProvider.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookDefinitionProvider.cs
new file mode 100644
index 000000000..4e5745b06
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookDefinitionProvider.cs
@@ -0,0 +1,60 @@
+using Volo.Abp.Identity.Localization;
+using Volo.Abp.Localization;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class IdentityWebhookDefinitionProvider : WebhookDefinitionProvider
+{
+ public override void Define(IWebhookDefinitionContext context)
+ {
+ context.Add(CreateIdentityRoleWebhooks());
+ context.Add(CreateIdentityUserWebhooks());
+ }
+
+ protected virtual WebhookDefinition[] CreateIdentityRoleWebhooks()
+ {
+ return new[]
+ {
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityRole.Create,
+ L("Webhooks:CreateRole"),
+ L("Webhooks:CreateRoleDesc")),
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityRole.Update,
+ L("Webhooks:UpdateRole"),
+ L("Webhooks:UpdateRoleDesc")),
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityRole.Delete,
+ L("Webhooks:DeleteRole"),
+ L("Webhooks:DeleteRoleDesc")),
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityRole.ChangeName,
+ L("Webhooks:ChangeRoleName"),
+ L("Webhooks:ChangeRoleNameDesc")),
+ };
+ }
+
+ protected virtual WebhookDefinition[] CreateIdentityUserWebhooks()
+ {
+ return new[]
+ {
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityUser.Create,
+ L("Webhooks:CreateUser"),
+ L("Webhooks:CreateUserDesc")),
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityUser.Update,
+ L("Webhooks:UpdateUser"),
+ L("Webhooks:UpdateUserDesc")),
+ new WebhookDefinition(
+ IdentityWebhookNames.IdentityUser.Delete,
+ L("Webhooks:DeleteUser"),
+ L("Webhooks:DeleteUserDesc")),
+ };
+ }
+
+ private static ILocalizableString L(string name)
+ {
+ return LocalizableString.Create(name);
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookNames.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookNames.cs
new file mode 100644
index 000000000..a190f8692
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/IdentityWebhookNames.cs
@@ -0,0 +1,22 @@
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public static class IdentityWebhookNames
+{
+ public const string GroupName = "abp.identity";
+ public static class IdentityRole
+ {
+ public const string Prefix = GroupName + ".roles";
+ public const string Create = Prefix + ".create";
+ public const string Update = Prefix + ".update";
+ public const string Delete = Prefix + ".delete";
+ public const string ChangeName = Prefix + ".change_name";
+ }
+
+ public static class IdentityUser
+ {
+ public const string Prefix = GroupName + ".users";
+ public const string Create = Prefix + ".create";
+ public const string Update = Prefix + ".update";
+ public const string Delete = Prefix + ".delete";
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/en.json b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/en.json
new file mode 100644
index 000000000..9687bcf0e
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/en.json
@@ -0,0 +1,19 @@
+{
+ "culture": "en",
+ "texts": {
+ "Webhooks:CreateRole": "Create Role",
+ "Webhooks:CreateRoleDesc": "A new role has been created",
+ "Webhooks:UpdateRole": "Update Role",
+ "Webhooks:UpdateRoleDesc": "A role has changed",
+ "Webhooks:DeleteRole": "Delete Role",
+ "Webhooks:DeleteRoleDesc": "Deleted Role",
+ "Webhooks:ChangeRoleName": "Change Role Name",
+ "Webhooks:ChangeRoleNameDesc": "The name of a role was changed",
+ "Webhooks:CreateUser": "Create User",
+ "Webhooks:CreateUserDesc": "A new user has been created",
+ "Webhooks:UpdateUser": "Update User",
+ "Webhooks:UpdateUserDesc": "A user has been changed",
+ "Webhooks:DeleteUser": "Delete User",
+ "Webhooks:DeleteUserDesc": "Deleted User"
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/zh-Hans.json b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/zh-Hans.json
new file mode 100644
index 000000000..853a91b01
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/Localization/Resources/zh-Hans.json
@@ -0,0 +1,19 @@
+{
+ "culture": "zh-Hans",
+ "texts": {
+ "Webhooks:CreateRole": "创建角色",
+ "Webhooks:CreateRoleDesc": "一个新角色已创建",
+ "Webhooks:UpdateRole": "编辑角色",
+ "Webhooks:UpdateRoleDesc": "一个角色属性已变更",
+ "Webhooks:DeleteRole": "删除角色",
+ "Webhooks:DeleteRoleDesc": "已删除角色",
+ "Webhooks:ChangeRoleName": "改变角色名称",
+ "Webhooks:ChangeRoleNameDesc": "一个角色的名称被更改",
+ "Webhooks:CreateUser": "创建用户",
+ "Webhooks:CreateUserDesc": "一个新用户已创建",
+ "Webhooks:UpdateUser": "编辑用户",
+ "Webhooks:UpdateUserDesc": "一个用户属性已变更",
+ "Webhooks:DeleteUser": "删除用户",
+ "Webhooks:DeleteUserDesc": "已删除用户"
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWebHooker.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWebHooker.cs
new file mode 100644
index 000000000..fb7e30913
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWebHooker.cs
@@ -0,0 +1,49 @@
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Entities.Events.Distributed;
+using Volo.Abp.EventBus.Distributed;
+using Volo.Abp.Identity;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class OrganizationUnitWebHooker :
+ IDistributedEventHandler>,
+ IDistributedEventHandler>,
+ IDistributedEventHandler>,
+ ITransientDependency
+{
+ private readonly IWebhookPublisher _webhookPublisher;
+
+ public OrganizationUnitWebHooker(
+ IWebhookPublisher webhookPublisher)
+ {
+ _webhookPublisher = webhookPublisher;
+ }
+
+ public async virtual Task HandleEventAsync(EntityCreatedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityRole.Create, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(EntityUpdatedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityRole.Update, eventData.Entity);
+ }
+
+ public async virtual Task HandleEventAsync(EntityDeletedEto eventData)
+ {
+ await PublishAsync(IdentityWebhookNames.IdentityRole.Delete, eventData.Entity);
+ }
+
+ protected async virtual Task PublishAsync(string webhookName, OrganizationUnitEto eto)
+ {
+ await _webhookPublisher.PublishAsync(
+ webhookName,
+ new OrganizationUnitWto
+ {
+ Id = eto.Id,
+ DisplayName = eto.DisplayName
+ },
+ eto.TenantId);
+ }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWto.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWto.cs
new file mode 100644
index 000000000..fb4929b7a
--- /dev/null
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.Webhooks.Identity/LINGYUN/Abp/Webhooks/Identity/OrganizationUnitWto.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace LINGYUN.Abp.Webhooks.Identity;
+
+public class OrganizationUnitWto
+{
+ public Guid Id { get; set; }
+
+ public string Code { get; set; }
+
+ public string DisplayName { get; set; }
+}
diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/Webhooks/WebhooksNames.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/Webhooks/WebhooksNames.cs
index 8b185a686..2332b9681 100644
--- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/Webhooks/WebhooksNames.cs
+++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/Webhooks/WebhooksNames.cs
@@ -2,5 +2,5 @@
public static class WebhooksNames
{
- public const string CheckConnect = "Abp.Webhooks.CheckConnect";
+ public const string CheckConnect = "abp.webhooks.check_connect";
}
diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj
index 85571cc58..79afc282d 100644
--- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj
+++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj
@@ -57,6 +57,7 @@
+
diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs
index cd3d2e9be..c6b452fbe 100644
--- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs
+++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs
@@ -7,6 +7,7 @@ using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.Serilog.Enrichers.Application;
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
+using LINGYUN.Abp.Webhooks.Identity;
using LINGYUN.Abp.WebhooksManagement;
using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore;
using Microsoft.AspNetCore.Builder;
@@ -38,6 +39,7 @@ namespace LY.MicroService.WebhooksManagement;
typeof(WebhooksManagementApplicationModule),
typeof(WebhooksManagementHttpApiModule),
typeof(WebhooksManagementEntityFrameworkCoreModule),
+ typeof(AbpWebhooksIdentityModule),
typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpEmailingExceptionHandlingModule),