diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index c3844d741..994839f02 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -591,17 +591,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rules-management", "rules-m EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rules-engine", "rules-engine", "{F7103498-8B5B-4698-AACE-9E949F732E77}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.RulesEngineManagement.Domain.Shared", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Domain.Shared\LINGYUN.Abp.RulesEngineManagement.Domain.Shared.csproj", "{2EAA690B-1395-4952-95A0-A52F929028C4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.RulesEngineManagement.Domain.Shared", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Domain.Shared\LINGYUN.Abp.RulesEngineManagement.Domain.Shared.csproj", "{2EAA690B-1395-4952-95A0-A52F929028C4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.RulesEngineManagement.Domain", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Domain\LINGYUN.Abp.RulesEngineManagement.Domain.csproj", "{722FE012-8F23-4558-9E8F-A37C02902058}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.RulesEngineManagement.Domain", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Domain\LINGYUN.Abp.RulesEngineManagement.Domain.csproj", "{722FE012-8F23-4558-9E8F-A37C02902058}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.RulesEngineManagement.Application.Contracts", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Application.Contracts\LINGYUN.Abp.RulesEngineManagement.Application.Contracts.csproj", "{79D3C6D6-6433-471D-B354-477E07CB08EE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.RulesEngineManagement.Application.Contracts", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Application.Contracts\LINGYUN.Abp.RulesEngineManagement.Application.Contracts.csproj", "{79D3C6D6-6433-471D-B354-477E07CB08EE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.RulesEngineManagement.Application", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Application\LINGYUN.Abp.RulesEngineManagement.Application.csproj", "{5A3B9F4D-E6CC-410F-B307-0E69CCA213F5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.RulesEngineManagement.Application", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Application\LINGYUN.Abp.RulesEngineManagement.Application.csproj", "{5A3B9F4D-E6CC-410F-B307-0E69CCA213F5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.RulesEngineManagement.EntityFrameworkCore", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.EntityFrameworkCore\LINGYUN.Abp.RulesEngineManagement.EntityFrameworkCore.csproj", "{4CDCD854-6E06-4076-AE94-53C1C1D7F6FA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.RulesEngineManagement.EntityFrameworkCore", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.EntityFrameworkCore\LINGYUN.Abp.RulesEngineManagement.EntityFrameworkCore.csproj", "{4CDCD854-6E06-4076-AE94-53C1C1D7F6FA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.RulesEngineManagement.HttpApi", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.HttpApi\LINGYUN.Abp.RulesEngineManagement.HttpApi.csproj", "{97062425-3379-4F8D-BFA2-D445C56C0801}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.RulesEngineManagement.HttpApi", "modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.HttpApi\LINGYUN.Abp.RulesEngineManagement.HttpApi.csproj", "{97062425-3379-4F8D-BFA2-D445C56C0801}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.IdentityServer.Portal", "modules\identityServer\LINGYUN.Abp.IdentityServer.Portal\LINGYUN.Abp.IdentityServer.Portal.csproj", "{5B20BA13-40FF-4743-AEEE-2E3F887F50C6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OpenIddict.Portal", "modules\openIddict\LINGYUN.Abp.OpenIddict.Portal\LINGYUN.Abp.OpenIddict.Portal.csproj", "{03EC70B8-912C-4FBE-94DD-6327F4F23021}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1537,6 +1541,14 @@ Global {97062425-3379-4F8D-BFA2-D445C56C0801}.Debug|Any CPU.Build.0 = Debug|Any CPU {97062425-3379-4F8D-BFA2-D445C56C0801}.Release|Any CPU.ActiveCfg = Release|Any CPU {97062425-3379-4F8D-BFA2-D445C56C0801}.Release|Any CPU.Build.0 = Release|Any CPU + {5B20BA13-40FF-4743-AEEE-2E3F887F50C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B20BA13-40FF-4743-AEEE-2E3F887F50C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B20BA13-40FF-4743-AEEE-2E3F887F50C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B20BA13-40FF-4743-AEEE-2E3F887F50C6}.Release|Any CPU.Build.0 = Release|Any CPU + {03EC70B8-912C-4FBE-94DD-6327F4F23021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03EC70B8-912C-4FBE-94DD-6327F4F23021}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03EC70B8-912C-4FBE-94DD-6327F4F23021}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03EC70B8-912C-4FBE-94DD-6327F4F23021}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1828,6 +1840,8 @@ Global {5A3B9F4D-E6CC-410F-B307-0E69CCA213F5} = {F7103498-8B5B-4698-AACE-9E949F732E77} {4CDCD854-6E06-4076-AE94-53C1C1D7F6FA} = {F7103498-8B5B-4698-AACE-9E949F732E77} {97062425-3379-4F8D-BFA2-D445C56C0801} = {F7103498-8B5B-4698-AACE-9E949F732E77} + {5B20BA13-40FF-4743-AEEE-2E3F887F50C6} = {0439B173-F41E-4CE0-A44A-CCB70328F272} + {03EC70B8-912C-4FBE-94DD-6327F4F23021} = {83E698F6-F8CD-4604-AB80-01A203389501} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230506071509_Add-Portal-Login.Designer.cs b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230506071509_Add-Portal-Login.Designer.cs new file mode 100644 index 000000000..3e59606c6 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230506071509_Add-Portal-Login.Designer.cs @@ -0,0 +1,868 @@ +// +using System; +using LY.MicroService.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations +{ + [DbContext(typeof(PlatformMigrationsDbContext))] + [Migration("20230506071509_Add-Portal-Login")] + partial class AddPortalLogin + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("ForceUpdate") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformPackages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("PackageId") + .HasColumnType("char(36)"); + + b.Property("SHA256") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); + + b.HasKey("Id"); + + b.HasIndex("PackageId", "Name"); + + b.ToTable("AppPlatformPackageBlobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Portal.Enterprise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Address") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Address"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("EnglishName") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("EnglishName"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LegalMan") + .HasMaxLength(60) + .HasColumnType("varchar(60)") + .HasColumnName("LegalMan"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("OrganizationCode") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("OrganizationCode"); + + b.Property("RegistrationCode") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("RegistrationCode"); + + b.Property("RegistrationDate") + .HasColumnType("datetime(6)"); + + b.Property("TaxCode") + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("TaxCode"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformEnterprises", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Navigation("Blobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230506071509_Add-Portal-Login.cs b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230506071509_Add-Portal-Login.cs new file mode 100644 index 000000000..a9aeabdbb --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230506071509_Add-Portal-Login.cs @@ -0,0 +1,62 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations +{ + /// + public partial class AddPortalLogin : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AppPlatformEnterprises", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EnglishName = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Address = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + LegalMan = table.Column(type: "varchar(60)", maxLength: 60, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TaxCode = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + OrganizationCode = table.Column(type: "varchar(16)", maxLength: 16, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RegistrationCode = table.Column(type: "varchar(30)", maxLength: 30, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RegistrationDate = table.Column(type: "datetime(6)", nullable: true), + ExpirationDate = table.Column(type: "datetime(6)", nullable: true), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformEnterprises", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppPlatformEnterprises"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230509024453_Add-Logo-Property-With-Portal.Designer.cs b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230509024453_Add-Logo-Property-With-Portal.Designer.cs new file mode 100644 index 000000000..e4f7e6171 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230509024453_Add-Logo-Property-With-Portal.Designer.cs @@ -0,0 +1,873 @@ +// +using System; +using LY.MicroService.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations +{ + [DbContext(typeof(PlatformMigrationsDbContext))] + [Migration("20230509024453_Add-Logo-Property-With-Portal")] + partial class AddLogoPropertyWithPortal + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "7.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("ForceUpdate") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformPackages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("PackageId") + .HasColumnType("char(36)"); + + b.Property("SHA256") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); + + b.HasKey("Id"); + + b.HasIndex("PackageId", "Name"); + + b.ToTable("AppPlatformPackageBlobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Portal.Enterprise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Address") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Address"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("EnglishName") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("EnglishName"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LegalMan") + .HasMaxLength(60) + .HasColumnType("varchar(60)") + .HasColumnName("LegalMan"); + + b.Property("Logo") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Logo"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("OrganizationCode") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("OrganizationCode"); + + b.Property("RegistrationCode") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("RegistrationCode"); + + b.Property("RegistrationDate") + .HasColumnType("datetime(6)"); + + b.Property("TaxCode") + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("TaxCode"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformEnterprises", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Navigation("Blobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230509024453_Add-Logo-Property-With-Portal.cs b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230509024453_Add-Logo-Property-With-Portal.cs new file mode 100644 index 000000000..3c19f9fbc --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20230509024453_Add-Logo-Property-With-Portal.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations +{ + /// + public partial class AddLogoPropertyWithPortal : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Logo", + table: "AppPlatformEnterprises", + type: "varchar(512)", + maxLength: 512, + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Logo", + table: "AppPlatformEnterprises"); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/PlatformMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/PlatformMigrationsDbContextModelSnapshot.cs index 16ba35529..45f54b448 100644 --- a/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/PlatformMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/PlatformMigrationsDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "7.0.1") + .HasAnnotation("ProductVersion", "7.0.2") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => @@ -734,6 +734,107 @@ namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations b.ToTable("AppPlatformPackageBlobs", (string)null); }); + modelBuilder.Entity("LINGYUN.Platform.Portal.Enterprise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Address") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Address"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("EnglishName") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("EnglishName"); + + b.Property("ExpirationDate") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LegalMan") + .HasMaxLength(60) + .HasColumnType("varchar(60)") + .HasColumnName("LegalMan"); + + b.Property("Logo") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Logo"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("OrganizationCode") + .HasMaxLength(16) + .HasColumnType("varchar(16)") + .HasColumnName("OrganizationCode"); + + b.Property("RegistrationCode") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("RegistrationCode"); + + b.Property("RegistrationDate") + .HasColumnType("datetime(6)"); + + b.Property("TaxCode") + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("TaxCode"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformEnterprises", (string)null); + }); + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => { b.HasOne("LINGYUN.Platform.Datas.Data", null) diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/LINGYUN/Abp/Elsa/Notifications/AbpElsaWorkflowNotificationHandler.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/LINGYUN/Abp/Elsa/Notifications/AbpElsaWorkflowNotificationHandler.cs index 007e51685..8ae8b88df 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/LINGYUN/Abp/Elsa/Notifications/AbpElsaWorkflowNotificationHandler.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/LINGYUN/Abp/Elsa/Notifications/AbpElsaWorkflowNotificationHandler.cs @@ -112,7 +112,7 @@ public class AbpElsaWorkflowNotificationHandler : await notificationSender.SendNofiterAsync( notificationName, notificationTemplate, - tenantId: currentTenant.Id ?? workflowInstance.GetTenantId(), + tenantId: executionContext.GetNotificationTenantId() ?? currentTenant.Id ?? workflowInstance.GetTenantId(), severity: severity); } catch (Exception ex) diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/README.md b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/README.md index d97e2812b..9817384d9 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/README.md +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Notifications/README.md @@ -1,67 +1,69 @@ -# LINGYUN.Abp.Elsa.Notifications - -工作流通知集成, 当工作流触发后, 发布相应事件通知 - -## 可用状态 - -* Faulted: 工作流执行出现错误 -* Cancelled: 工作流取消 -* Completed: 工作流执行完毕 -* Suspended: 工作流暂停 - - -## 配置使用 - -```csharp - - [DependsOn( - typeof(AbpElsaNotificationsModule) - )] - public class YouProjectModule : AbpModule - { - } -``` - -```csharp - // 定义通知 - public class DemoNotificationDefinitionProvider : NotificationDefinitionProvider - { - public override void Define(INotificationDefinitionContext context) - { - var demoGroup = context.AddGroup("Group"); - - // 由于通知的多样性, 需要使用模板消息来传递数据 - demoGroup.AddNotification("Faulted") - .WithTemplate(template => { }); - demoGroup.AddNotification("Cancelled") - .WithTemplate(template => { }); - demoGroup.AddNotification("Suspended") - .WithTemplate(template => { }); - demoGroup.AddNotification("Completed") - .WithTemplate(template => { }); - } - } -``` - -```csharp - - // 定义工作流 - public class DemoWorkflow : IWorkflow - { - public void Build(IWorkflowBuilder builder) - { - builder - .WithFaultedNotification("Faulted") - .WithCancelledNotification("Cancelled") - .WithSuspendedNotification("Suspended") - .WithCompletedNotification("Completed") - .SetVariable("demo", context => - { - // 可传递自定义参数, 将作为瞬时变量写入到发布的通知数据中 +# LINGYUN.Abp.Elsa.Notifications + +工作流通知集成, 当工作流触发后, 发布相应事件通知 + +## 可用状态 + +* Faulted: 工作流执行出现错误 +* Cancelled: 工作流取消 +* Completed: 工作流执行完毕 +* Suspended: 工作流暂停 + + +## 配置使用 + +```csharp + + [DependsOn( + typeof(AbpElsaNotificationsModule) + )] + public class YouProjectModule : AbpModule + { + } +``` + +```csharp + // 定义通知 + public class DemoNotificationDefinitionProvider : NotificationDefinitionProvider + { + public override void Define(INotificationDefinitionContext context) + { + var demoGroup = context.AddGroup("Group"); + + // 由于通知的多样性, 需要使用模板消息来传递数据 + demoGroup.AddNotification("Faulted") + .WithTemplate(template => { }); + demoGroup.AddNotification("Cancelled") + .WithTemplate(template => { }); + demoGroup.AddNotification("Suspended") + .WithTemplate(template => { }); + demoGroup.AddNotification("Completed") + .WithTemplate(template => { }); + } + } +``` + +```csharp + + // 定义工作流 + public class DemoWorkflow : IWorkflow + { + public void Build(IWorkflowBuilder builder) + { + builder + .WithFaultedNotification("Faulted") + .WithCancelledNotification("Cancelled") + .WithSuspendedNotification("Suspended") + .WithCompletedNotification("Completed") + .SetVariable("demo", context => + { + // 可传递自定义参数, 将作为瞬时变量写入到发布的通知数据中 context.WithNotificationData("demo", "demo"); - }) - .WriteLine("Start a workflow.") - .WriteLine("Workflow finished."); - } - } + // 自定义用于发布通知的租户标识 + context.WithNotificationTenantId(Guid.NewGuid()); + }) + .WriteLine("Start a workflow.") + .WriteLine("Workflow finished."); + } + } ``` \ No newline at end of file diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Notifications/AbpWorkflowExecutionContextNotificationsExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Notifications/AbpWorkflowExecutionContextNotificationsExtensions.cs index f5531a058..bf8024b47 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Notifications/AbpWorkflowExecutionContextNotificationsExtensions.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa/LINGYUN/Abp/Elsa/Notifications/AbpWorkflowExecutionContextNotificationsExtensions.cs @@ -1,14 +1,50 @@ using Elsa.Services.Models; +using System; using System.Collections.Generic; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.Elsa.Notifications; public static class AbpWorkflowExecutionContextNotificationsExtensions { private const string NotificationDataKey = AbpWorkflowBuilderNotificationsExtensions.NotificationPrefix + "Data_"; + #region MultiTenancy + + public static void WithNotificationTenantId(this ActivityExecutionContext context, Guid? tenantId) + { + context.WorkflowExecutionContext.WithNotificationTenantId(tenantId); + } + + public static void WithNotificationTenantId(this WorkflowExecutionContext context, Guid? tenantId) + { + if (tenantId.HasValue) + { + context.WithNotificationData(nameof(IMultiTenant.TenantId), tenantId.Value); + } + } + + public static Guid? GetNotificationTenantId(this ActivityExecutionContext context) + { + return context.WorkflowExecutionContext.GetNotificationTenantId(); + } + + public static Guid? GetNotificationTenantId(this WorkflowExecutionContext context) + { + var data = context.GetNotificationData(); + if (data.TryGetValue(nameof(IMultiTenant.TenantId), out var tenantIdObj) && + tenantIdObj != null && Guid.TryParse(tenantIdObj.ToString(), out Guid tenantId)) + { + return tenantId; + } + + return null; + } + + #endregion + public static void WithNotificationData(this ActivityExecutionContext context, string key, object data) { - context.WorkflowExecutionContext.SetTransientVariable(key, data); + context.WorkflowExecutionContext.WithNotificationData(key, data); } public static void WithNotificationData(this WorkflowExecutionContext context, string key, object data) diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/FodyWeavers.xml b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/FodyWeavers.xml new file mode 100644 index 000000000..5d6962159 --- /dev/null +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/FodyWeavers.xsd b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/FodyWeavers.xsd new file mode 100644 index 000000000..3f3946e28 --- /dev/null +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/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/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN.Abp.IdentityServer.Portal.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN.Abp.IdentityServer.Portal.csproj new file mode 100644 index 000000000..63eba79cc --- /dev/null +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN.Abp.IdentityServer.Portal.csproj @@ -0,0 +1,19 @@ + + + + + + + net7.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN/Abp/IdentityServer/Portal/AbpIdentityServerPortalModule.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN/Abp/IdentityServer/Portal/AbpIdentityServerPortalModule.cs new file mode 100644 index 000000000..994c84d6c --- /dev/null +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN/Abp/IdentityServer/Portal/AbpIdentityServerPortalModule.cs @@ -0,0 +1,40 @@ +using LINGYUN.Platform; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.IdentityServer; +using Volo.Abp.IdentityServer.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.IdentityServer.Portal; + +[DependsOn( + typeof(AbpIdentityServerDomainModule), + typeof(PlatformDomainModule))] +public class AbpIdentityServerPortalModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + + PreConfigure(builder => + { + builder.AddExtensionGrantValidator(); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/Abp/IdentityServer/Portal/Localization"); + }); + } +} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN/Abp/IdentityServer/Portal/PortalGrantValidator.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN/Abp/IdentityServer/Portal/PortalGrantValidator.cs new file mode 100644 index 000000000..eb95ca326 --- /dev/null +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Portal/LINGYUN/Abp/IdentityServer/Portal/PortalGrantValidator.cs @@ -0,0 +1,255 @@ +using IdentityModel; +using IdentityServer4.Configuration; +using IdentityServer4.Events; +using IdentityServer4.Models; +using IdentityServer4.Services; +using IdentityServer4.Validation; +using LINGYUN.Platform.Portal; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Volo.Abp.Identity; +using Volo.Abp.IdentityServer; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Security.Claims; +using Volo.Abp.Uow; +using static IdentityModel.OidcConstants; +using IdentityUser = Volo.Abp.Identity.IdentityUser; + +namespace LINGYUN.Abp.IdentityServer.Portal; +public class PortalGrantValidator : IExtensionGrantValidator +{ + public const string ProviderName = "portal"; + public string GrantType => ProviderName; + + private readonly ILogger _logger; + + private readonly IdentityServerOptions _options; + + private readonly IEventService _events; + private readonly IResourceOwnerPasswordValidator _resourceOwnerValidator; + private readonly IdentitySecurityLogManager _identitySecurityLogManager; + private readonly UserManager _userManager; + + private readonly ICurrentTenant _currentTenant; + private readonly IEnterpriseRepository _enterpriseRepository; + + public PortalGrantValidator( + ILogger logger, + IOptions options, + IEventService events, + IResourceOwnerPasswordValidator resourceOwnerValidator, + IdentitySecurityLogManager identitySecurityLogManager, + UserManager userManager, + ICurrentTenant currentTenant, + IEnterpriseRepository enterpriseRepository) + { + _logger = logger; + _options = options.Value; + _events = events; + _resourceOwnerValidator = resourceOwnerValidator; + _identitySecurityLogManager = identitySecurityLogManager; + _userManager = userManager; + _currentTenant = currentTenant; + _enterpriseRepository = enterpriseRepository; + } + + [UnitOfWork] + public async virtual Task ValidateAsync(ExtensionGrantValidationContext context) + { + /* ************************************ + * + * 启用平台登录后,需要管理员在宿主端定义企业信息, 并关联到某个租户 + * + * 1、用户使用protal发起登录请求 + * 2、检查是否携带企业标识字段 EnterpriseId + * 2.1、未携带 EnterpriseId 字段, 检索关联了租户信息的企业列表, 通过自定义标头反馈给用户端 + * 2.2、检索关联 EnterpriseId 的租户信息, 切换指定租户, 通过 password 方式来进行登录验证 + * 3、登录成功返回token + * + * *************************************/ + + var parameters = context.Request.Raw; + + Guid? tenantId = null; + using (_currentTenant.Change(null)) + { + var enterprise = parameters.Get("EnterpriseId"); + if (enterprise.IsNullOrWhiteSpace() || !Guid.TryParse(enterprise, out var enterpriseId)) + { + // TODO: configurabled + var enterprises = await _enterpriseRepository.GetEnterprisesInTenantListAsync(25); + + context.Result = new GrantValidationResult( + TokenRequestErrors.InvalidGrant, + customResponse: new Dictionary + { + // 是否可直接选择的模式 + { "Enterprises", JsonConvert.SerializeObject(enterprises.Select(x => new { Id = x.Id, Name = x.Name, Logo = x.Logo })) }, + }); + return; + } + + tenantId = await _enterpriseRepository.GetEnterpriseInTenantAsync(enterpriseId); + } + + using (_currentTenant.Change(tenantId)) + { + var validatedRequest = new ValidatedTokenRequest + { + Raw = parameters ?? throw new ArgumentNullException(nameof(parameters)), + Options = _options + }; + + var userName = parameters.Get(OidcConstants.TokenRequest.UserName); + var password = parameters.Get(OidcConstants.TokenRequest.Password); + + if (userName.IsNullOrWhiteSpace()) + { + context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant); + return; + } + + if (password.IsNullOrWhiteSpace()) + { + password = ""; + } + + if (userName.Length > _options.InputLengthRestrictions.UserName || + password.Length > _options.InputLengthRestrictions.Password) + { + context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant); + return; + } + + var resourceOwnerContext = new ResourceOwnerPasswordValidationContext + { + UserName = userName, + Password = password, + Request = validatedRequest + }; + await _resourceOwnerValidator.ValidateAsync(resourceOwnerContext); + + if (resourceOwnerContext.Result.IsError) + { + // protect against bad validator implementations + resourceOwnerContext.Result.Error ??= OidcConstants.TokenErrors.InvalidGrant; + + if (resourceOwnerContext.Result.Error == OidcConstants.TokenErrors.UnsupportedGrantType) + { + _logger.LogError("Resource owner password credential grant type not supported"); + + await RaiseFailedResourceOwnerAuthenticationEventAsync(userName, "password grant type not supported", resourceOwnerContext.Request.Client.ClientId); + + context.Result = new GrantValidationResult(TokenRequestErrors.UnsupportedGrantType, customResponse: resourceOwnerContext.Result.CustomResponse); + return; + } + + var errorDescription = "invalid_username_or_password"; + + if (!resourceOwnerContext.Result.ErrorDescription.IsNullOrWhiteSpace()) + { + errorDescription = resourceOwnerContext.Result.ErrorDescription; + } + + _logger.LogInformation("User authentication failed: ", errorDescription ?? resourceOwnerContext.Result.Error); + await RaiseFailedResourceOwnerAuthenticationEventAsync(userName, errorDescription, context.Request.Client.ClientId); + + context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, errorDescription, resourceOwnerContext.Result.CustomResponse); + + return; + } + + if (resourceOwnerContext.Result.Subject == null) + { + var error = "User authentication failed: no principal returned"; + _logger.LogError(error); + + await RaiseFailedResourceOwnerAuthenticationEventAsync(userName, error, context.Request.Client.ClientId); + + context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant); + + return; + } + + var currentUser = await _userManager.GetUserAsync(resourceOwnerContext.Result.Subject); + + await _events.RaiseAsync(new UserLoginSuccessEvent(userName, currentUser.Id.ToString(), currentUser.Name)); + + await SetSuccessResultAsync(context, currentUser); + } + } + + protected async virtual Task SetSuccessResultAsync(ExtensionGrantValidationContext context, IdentityUser user) + { + var sub = await _userManager.GetUserIdAsync(user); + + _logger.LogInformation("Credentials validated for username: {username}", user.UserName); + + var additionalClaims = new List(); + + await AddCustomClaimsAsync(additionalClaims, user, context); + + context.Result = new GrantValidationResult( + sub, + AuthenticationMethods.ConfirmationBySms, + additionalClaims.ToArray() + ); + + await SaveSecurityLogAsync( + context, + user, + IdentityServerSecurityLogActionConsts.LoginSucceeded); + } + + protected async virtual Task SaveSecurityLogAsync( + ExtensionGrantValidationContext context, + IdentityUser user, + string action) + { + var logContext = new IdentitySecurityLogContext + { + Identity = IdentityServerSecurityLogIdentityConsts.IdentityServer, + Action = action, + UserName = user.UserName, + ClientId = await FindClientIdAsync(context) + }; + logContext.WithProperty("GrantType", GrantType); + + await _identitySecurityLogManager.SaveAsync(logContext); + } + + protected virtual Task FindClientIdAsync(ExtensionGrantValidationContext context) + { + return Task.FromResult(context.Request?.Client?.ClientId); + } + + protected virtual Task AddCustomClaimsAsync( + List customClaims, + IdentityUser user, + ExtensionGrantValidationContext context) + { + if (user.TenantId.HasValue) + { + customClaims.Add( + new Claim( + AbpClaimTypes.TenantId, + user.TenantId?.ToString() + ) + ); + } + + return Task.CompletedTask; + } + + private Task RaiseFailedResourceOwnerAuthenticationEventAsync(string userName, string error, string clientId) + { + return _events.RaiseAsync(new UserLoginFailureEvent(userName, error, interactive: false, clientId: clientId)); + } +} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/FodyWeavers.xml b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/FodyWeavers.xsd b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/FodyWeavers.xsd new file mode 100644 index 000000000..3f3946e28 --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/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/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN.Abp.OpenIddict.Portal.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN.Abp.OpenIddict.Portal.csproj new file mode 100644 index 000000000..d1d05efdb --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN.Abp.OpenIddict.Portal.csproj @@ -0,0 +1,19 @@ + + + + + + + net7.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/AbpOpenIddictPortalModule.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/AbpOpenIddictPortalModule.cs new file mode 100644 index 000000000..35fb9b61d --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/AbpOpenIddictPortalModule.cs @@ -0,0 +1,31 @@ +using LINGYUN.Platform; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using Volo.Abp.OpenIddict; +using Volo.Abp.OpenIddict.ExtensionGrantTypes; + +namespace LINGYUN.Abp.OpenIddict.Portal; + +[DependsOn( + typeof(AbpOpenIddictAspNetCoreModule), + typeof(PlatformDomainModule))] +public class AbpOpenIddictPortalModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(builder => + { + builder.AllowPortalFlow(); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Grants.TryAdd( + PortalTokenExtensionGrantConsts.GrantType, + new PortalTokenExtensionGrant()); + }); + } +} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/PortalTokenExtensionGrant.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/PortalTokenExtensionGrant.cs new file mode 100644 index 000000000..d5ad99978 --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/PortalTokenExtensionGrant.cs @@ -0,0 +1,328 @@ +using LINGYUN.Platform.Portal; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using OpenIddict.Abstractions; +using OpenIddict.Server.AspNetCore; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Identity; +using Volo.Abp.MultiTenancy; +using Volo.Abp.OpenIddict; +using Volo.Abp.OpenIddict.ExtensionGrantTypes; +using Volo.Abp.Uow; +using Volo.Abp.Validation; +using IdentityUser = Volo.Abp.Identity.IdentityUser; +using SignInResult = Microsoft.AspNetCore.Identity.SignInResult; + +namespace LINGYUN.Abp.OpenIddict.Portal; +public class PortalTokenExtensionGrant : ITokenExtensionGrant +{ + public string Name => PortalTokenExtensionGrantConsts.GrantType; + + protected IAbpLazyServiceProvider LazyServiceProvider { get; set; } + protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService(); + protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService(); + protected IEnterpriseRepository EnterpriseRepository => LazyServiceProvider.LazyGetRequiredService(); + protected SignInManager SignInManager => LazyServiceProvider.LazyGetRequiredService>(); + protected IdentityUserManager UserManager => LazyServiceProvider.LazyGetRequiredService(); + protected IOpenIddictScopeManager ScopeManager => LazyServiceProvider.LazyGetRequiredService(); + protected AbpOpenIddictClaimDestinationsManager OpenIddictClaimDestinationsManager => LazyServiceProvider.LazyGetRequiredService(); + protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService(); + protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance); + protected IServiceScopeFactory ServiceScopeFactory => LazyServiceProvider.LazyGetRequiredService(); + protected IOptions AbpIdentityOptions => LazyServiceProvider.LazyGetRequiredService>(); + protected IOptions IdentityOptions => LazyServiceProvider.LazyGetRequiredService>(); + protected IOptions MultiTenancyOptions => LazyServiceProvider.LazyGetRequiredService>(); + protected IdentitySecurityLogManager IdentitySecurityLogManager => LazyServiceProvider.LazyGetRequiredService(); + + public async virtual Task HandleAsync(ExtensionGrantContext context) + { + LazyServiceProvider = context.HttpContext.RequestServices.GetRequiredService(); + + using var scope = ServiceScopeFactory.CreateScope(); + using var unitOfWork = UnitOfWorkManager.Begin(); + var enterprise = context.Request.GetParameter("EnterpriseId")?.ToString(); + + Guid? tenantId = null; + using (CurrentTenant.Change(null)) + { + if (enterprise.IsNullOrWhiteSpace() || !Guid.TryParse(enterprise, out var enterpriseId)) + { + // TODO: configurabled + var enterprises = await EnterpriseRepository.GetEnterprisesInTenantListAsync(25); + + var properties = new AuthenticationProperties( + new Dictionary + { + [OpenIddictServerAspNetCoreConstants.Properties.Error] = OpenIddictConstants.Errors.InvalidGrant, + [OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] = "invalid_enterprise" + }, + new Dictionary + { + // 是否可直接选择的模式 + { "Enterprises", JsonConvert.SerializeObject(enterprises.Select(x => new { Id = x.Id, Name = x.Name, Logo = x.Logo })) }, + } + ); + return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); + } + + tenantId = await EnterpriseRepository.GetEnterpriseInTenantAsync(enterpriseId); + } + + using (CurrentTenant.Change(tenantId)) + { + return await HandlePasswordAsync(context); + } + } + + protected virtual async Task HandlePasswordAsync(ExtensionGrantContext context) + { + await ReplaceEmailToUsernameOfInputIfNeeds(context.Request); + + IdentityUser user = null; + + if (AbpIdentityOptions.Value.ExternalLoginProviders.Any()) + { + foreach (var externalLoginProviderInfo in AbpIdentityOptions.Value.ExternalLoginProviders.Values) + { + var externalLoginProvider = (IExternalLoginProvider)context.HttpContext.RequestServices + .GetRequiredService(externalLoginProviderInfo.Type); + + if (await externalLoginProvider.TryAuthenticateAsync(context.Request.Username, context.Request.Password)) + { + user = await UserManager.FindByNameAsync(context.Request.Username); + if (user == null) + { + user = await externalLoginProvider.CreateUserAsync(context.Request.Username, externalLoginProviderInfo.Name); + } + else + { + await externalLoginProvider.UpdateUserAsync(user, externalLoginProviderInfo.Name); + } + + return await SetSuccessResultAsync(context, user); + } + } + } + + await IdentityOptions.SetAsync(); + + user = await UserManager.FindByNameAsync(context.Request.Username); + if (user == null) + { + Logger.LogInformation("No user found matching username: {username}", context.Request.Username); + + var properties = new AuthenticationProperties(new Dictionary + { + [OpenIddictServerAspNetCoreConstants.Properties.Error] = OpenIddictConstants.Errors.InvalidGrant, + [OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] = "Invalid username or password!" + }); + + await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext() + { + Identity = OpenIddictSecurityLogIdentityConsts.OpenIddict, + Action = OpenIddictSecurityLogActionConsts.LoginInvalidUserName, + UserName = context.Request.Username, + ClientId = context.Request.ClientId + }); + + return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); + } + + var result = await SignInManager.CheckPasswordSignInAsync(user, context.Request.Password, true); + if (!result.Succeeded) + { + string errorDescription; + if (result.IsLockedOut) + { + Logger.LogInformation("Authentication failed for username: {username}, reason: locked out", context.Request.Username); + errorDescription = "The user account has been locked out due to invalid login attempts. Please wait a while and try again."; + } + else if (result.IsNotAllowed) + { + Logger.LogInformation("Authentication failed for username: {username}, reason: not allowed", context.Request.Username); + errorDescription = "You are not allowed to login! Your account is inactive or needs to confirm your email/phone number."; + } + else + { + Logger.LogInformation("Authentication failed for username: {username}, reason: invalid credentials", context.Request.Username); + errorDescription = "Invalid username or password!"; + } + + var properties = new AuthenticationProperties(new Dictionary + { + [OpenIddictServerAspNetCoreConstants.Properties.Error] = OpenIddictConstants.Errors.InvalidGrant, + [OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] = errorDescription + }); + + return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); + } + + if (await IsTfaEnabledAsync(user)) + { + return await HandleTwoFactorLoginAsync(context, user); + } + + await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext + { + Identity = OpenIddictSecurityLogIdentityConsts.OpenIddict, + Action = result.ToIdentitySecurityLogAction(), + UserName = context.Request.Username, + ClientId = context.Request.ClientId + }); + + return await SetSuccessResultAsync(context, user); + } + + protected virtual async Task ReplaceEmailToUsernameOfInputIfNeeds(OpenIddictRequest request) + { + if (!ValidationHelper.IsValidEmailAddress(request.Username)) + { + return; + } + + var userByUsername = await UserManager.FindByNameAsync(request.Username); + if (userByUsername != null) + { + return; + } + + var userByEmail = await UserManager.FindByEmailAsync(request.Username); + if (userByEmail == null) + { + return; + } + + request.Username = userByEmail.UserName; + } + + protected virtual async Task HandleTwoFactorLoginAsync(ExtensionGrantContext context, IdentityUser user) + { + var twoFactorProvider = context.Request.GetParameter("TwoFactorProvider")?.ToString(); + var twoFactorCode = context.Request.GetParameter("TwoFactorCode")?.ToString(); ; + if (!twoFactorProvider.IsNullOrWhiteSpace() && !twoFactorCode.IsNullOrWhiteSpace()) + { + var providers = await UserManager.GetValidTwoFactorProvidersAsync(user); + if (providers.Contains(twoFactorProvider) && await UserManager.VerifyTwoFactorTokenAsync(user, twoFactorProvider, twoFactorCode)) + { + return await SetSuccessResultAsync(context, user); + } + + Logger.LogInformation("Authentication failed for username: {username}, reason: InvalidAuthenticatorCode", context.Request.Username); + + var properties = new AuthenticationProperties(new Dictionary + { + [OpenIddictServerAspNetCoreConstants.Properties.Error] = OpenIddictConstants.Errors.InvalidGrant, + [OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] = "Invalid authenticator code!" + }); + + return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); + } + else + { + Logger.LogInformation("Authentication failed for username: {username}, reason: RequiresTwoFactor", context.Request.Username); + var twoFactorToken = await UserManager.GenerateUserTokenAsync(user, TokenOptions.DefaultProvider, nameof(SignInResult.RequiresTwoFactor)); + + await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext + { + Identity = OpenIddictSecurityLogIdentityConsts.OpenIddict, + Action = OpenIddictSecurityLogActionConsts.LoginRequiresTwoFactor, + UserName = context.Request.Username, + ClientId = context.Request.ClientId + }); + + var properties = new AuthenticationProperties( + items: new Dictionary + { + [OpenIddictServerAspNetCoreConstants.Properties.Error] = OpenIddictConstants.Errors.InvalidGrant, + [OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] = + nameof(SignInResult.RequiresTwoFactor), + }, + parameters: new Dictionary + { + ["userId"] = user.Id.ToString("N"), + ["twoFactorToken"] = twoFactorToken + }); + + return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); + } + } + + protected virtual async Task SetSuccessResultAsync(ExtensionGrantContext context, IdentityUser user) + { + // Create a new ClaimsPrincipal containing the claims that + // will be used to create an id_token, a token or a code. + var principal = await SignInManager.CreateUserPrincipalAsync(user); + + principal.SetScopes(context.Request.GetScopes()); + principal.SetResources(await GetResourcesAsync(context.Request.GetScopes())); + + await SetClaimsDestinationsAsync(principal); + + await IdentitySecurityLogManager.SaveAsync( + new IdentitySecurityLogContext + { + Identity = OpenIddictSecurityLogIdentityConsts.OpenIddict, + Action = OpenIddictSecurityLogActionConsts.LoginSucceeded, + UserName = context.Request.Username, + ClientId = context.Request.ClientId + } + ); + + if (user.TenantId.HasValue) + { + AbpMultiTenancyCookieHelper.SetTenantCookie( + context.HttpContext, + user.TenantId, + MultiTenancyOptions.Value.TenantKey); + } + + return new Microsoft.AspNetCore.Mvc.SignInResult(OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, principal); + } + + protected virtual async Task IsTfaEnabledAsync(IdentityUser user) + { + return UserManager.SupportsUserTwoFactor && + await UserManager.GetTwoFactorEnabledAsync(user) && + (await UserManager.GetValidTwoFactorProvidersAsync(user)).Count > 0; + } + + protected virtual async Task> GetResourcesAsync(ImmutableArray scopes) + { + var resources = new List(); + if (!scopes.Any()) + { + return resources; + } + + await foreach (var resource in ScopeManager.ListResourcesAsync(scopes)) + { + resources.Add(resource); + } + return resources; + } + + protected virtual async Task SetClaimsDestinationsAsync(ClaimsPrincipal principal) + { + await OpenIddictClaimDestinationsManager.SetAsync(principal); + } + + public virtual ForbidResult Forbid(AuthenticationProperties properties, params string[] authenticationSchemes) + { + return new ForbidResult( + authenticationSchemes, + properties); + } +} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/PortalTokenExtensionGrantConsts.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/PortalTokenExtensionGrantConsts.cs new file mode 100644 index 000000000..82d650889 --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/LINGYUN/Abp/OpenIddict/Portal/PortalTokenExtensionGrantConsts.cs @@ -0,0 +1,5 @@ +namespace LINGYUN.Abp.OpenIddict.Portal; +public static class PortalTokenExtensionGrantConsts +{ + public const string GrantType = "portal"; +} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/Microsoft/Extensions/DependencyInjection/PortalOpenIddictServerBuilderExtensions.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/Microsoft/Extensions/DependencyInjection/PortalOpenIddictServerBuilderExtensions.cs new file mode 100644 index 000000000..43d9cbf9a --- /dev/null +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.Portal/Microsoft/Extensions/DependencyInjection/PortalOpenIddictServerBuilderExtensions.cs @@ -0,0 +1,11 @@ +using LINGYUN.Abp.OpenIddict.Portal; + +namespace Microsoft.Extensions.DependencyInjection; + +public static class PortalOpenIddictServerBuilderExtensions +{ + public static OpenIddictServerBuilder AllowPortalFlow(this OpenIddictServerBuilder builder) + { + return builder.AllowCustomFlow(PortalTokenExtensionGrantConsts.GrantType); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Portal/EnterpriseConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Portal/EnterpriseConsts.cs new file mode 100644 index 000000000..2f35794d0 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Portal/EnterpriseConsts.cs @@ -0,0 +1,12 @@ +namespace LINGYUN.Platform.Portal; +public static class EnterpriseConsts +{ + public static int MaxNameLength { get; set; } = 255; + public static int MaxEnglishNameLength { get; set; } = 512; + public static int MaxLogoLength { get; set; } = 512; + public static int MaxAddressLength { get; set; } = 255; + public static int MaxLegalManLength { get; set; } = 60; + public static int MaxTaxCodeLength { get; set; } = 40; + public static int MaxOrganizationCodeLength { get; set; } = 16; + public static int MaxRegistrationCodeLength { get; set; } = 30; +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs new file mode 100644 index 000000000..890c4bdd8 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs @@ -0,0 +1,109 @@ +using System; +using Volo.Abp; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities.Auditing; + +namespace LINGYUN.Platform.Portal; +/// +/// 企业信息 +/// +public class Enterprise : FullAuditedAggregateRoot +{ + /// + /// 租户标识 + /// + public virtual Guid? TenantId { get; protected set; } + /// + /// 名称 + /// + public virtual string Name { get; protected set; } + /// + /// 英文名称 + /// + public virtual string EnglishName { get; set; } + /// + /// Logo + /// + public virtual string Logo { get; set; } + /// + /// 地址 + /// + public virtual string Address { get; set; } + /// + /// 法人代表 + /// + public virtual string LegalMan { get; set; } + /// + /// 税务登记号 + /// + public virtual string TaxCode { get; set; } + /// + /// 组织机构代码 + /// + public virtual string OrganizationCode { get; protected set; } + /// + /// 注册代码 + /// + public virtual string RegistrationCode { get; protected set; } + /// + /// 注册日期 + /// + public virtual DateTime? RegistrationDate { get; protected set; } + /// + /// 过期日期 + /// + public virtual DateTime? ExpirationDate { get; protected set; } + protected Enterprise() + { + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public Enterprise( + string name, + string address, + string taxCode, + string organizationCode = null, + string registrationCode = null, + DateTime? registrationDate = null, + DateTime? expirationDate = null, + Guid? tenantId = null) + { + Address = Check.Length(address, nameof(address), EnterpriseConsts.MaxAddressLength); + TaxCode = Check.Length(taxCode, nameof(taxCode), EnterpriseConsts.MaxTaxCodeLength); + TenantId = tenantId; + + SetName(name); + SetOrganization(organizationCode); + SetRegistration(registrationCode, registrationDate, expirationDate); + + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public void SetTenantId(Guid? tenantId = null) + { + TenantId = tenantId; + } + + public void SetName(string name, string englishName = null) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), EnterpriseConsts.MaxNameLength); + EnglishName = Check.Length(englishName, nameof(englishName), EnterpriseConsts.MaxEnglishNameLength); + } + + public void SetOrganization(string organizationCode) + { + OrganizationCode = Check.Length(organizationCode, nameof(organizationCode), EnterpriseConsts.MaxOrganizationCodeLength); + } + + public void SetRegistration( + string registrationCode, + DateTime? registrationDate = null, + DateTime? expirationDate = null) + { + RegistrationCode = Check.Length(registrationCode, nameof(registrationCode), EnterpriseConsts.MaxRegistrationCodeLength); + RegistrationDate = registrationDate; + ExpirationDate = expirationDate; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs new file mode 100644 index 000000000..c816564d4 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace LINGYUN.Platform.Portal; +public interface IEnterpriseRepository : IBasicRepository +{ + Task> GetEnterprisesInTenantListAsync( + int maxResultCount = 10, + CancellationToken cancellationToken = default); + + Task GetEnterpriseInTenantAsync( + Guid id, + CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs index acfac2339..4684c49b1 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs @@ -1,24 +1,26 @@ -using LINGYUN.Platform.Datas; -using LINGYUN.Platform.Layouts; -using LINGYUN.Platform.Menus; +using LINGYUN.Platform.Datas; +using LINGYUN.Platform.Layouts; +using LINGYUN.Platform.Menus; using LINGYUN.Platform.Packages; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore; - -namespace LINGYUN.Platform.EntityFrameworkCore -{ - [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] - public interface IPlatformDbContext : IEfCoreDbContext - { - DbSet Menus { get; } - DbSet Layouts { get; } - DbSet RoleMenus { get; } +using LINGYUN.Platform.Portal; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] + public interface IPlatformDbContext : IEfCoreDbContext + { + DbSet Menus { get; } + DbSet Layouts { get; } + DbSet RoleMenus { get; } DbSet UserMenus { get; } - DbSet UserFavoriteMenus { get; } - DbSet Datas { get; } - DbSet DataItems { get; } - DbSet Packages { get; } - DbSet PackageBlobs { get; } - } -} + DbSet UserFavoriteMenus { get; } + DbSet Datas { get; } + DbSet DataItems { get; } + DbSet Packages { get; } + DbSet PackageBlobs { get; } + DbSet Enterprises { get; } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs index 7899dcf4f..72f504d0d 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs @@ -1,36 +1,38 @@ -using LINGYUN.Platform.Datas; -using LINGYUN.Platform.Layouts; -using LINGYUN.Platform.Menus; +using LINGYUN.Platform.Datas; +using LINGYUN.Platform.Layouts; +using LINGYUN.Platform.Menus; using LINGYUN.Platform.Packages; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore; - -namespace LINGYUN.Platform.EntityFrameworkCore -{ - [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] - public class PlatformDbContext : AbpDbContext, IPlatformDbContext - { +using LINGYUN.Platform.Portal; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] + public class PlatformDbContext : AbpDbContext, IPlatformDbContext + { public DbSet RoleMenus { get; set; } public DbSet UserMenus { get; set; } - public DbSet UserFavoriteMenus { get; set; } - public DbSet Menus { get; set; } - public DbSet Layouts { get; set; } + public DbSet UserFavoriteMenus { get; set; } + public DbSet Menus { get; set; } + public DbSet Layouts { get; set; } public DbSet Datas { get; set; } - public DbSet DataItems { get; set; } + public DbSet DataItems { get; set; } public DbSet Packages { get; set; } - public DbSet PackageBlobs { get; set; } - public PlatformDbContext(DbContextOptions options) - : base(options) - { - - } - - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - - builder.ConfigurePlatform(); - } - } -} + public DbSet PackageBlobs { get; set; } + public DbSet Enterprises { get; set; } + public PlatformDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.ConfigurePlatform(); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs index b83cd932b..8c28a54de 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs @@ -3,12 +3,14 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; using LINGYUN.Platform.Packages; +using LINGYUN.Platform.Portal; using LINGYUN.Platform.Routes; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System; using Volo.Abp; using Volo.Abp.EntityFrameworkCore.Modeling; +using static System.Runtime.CompilerServices.RuntimeHelpers; namespace LINGYUN.Platform.EntityFrameworkCore { @@ -241,6 +243,40 @@ namespace LINGYUN.Platform.EntityFrameworkCore x.HasIndex(i => new { i.PackageId, i.Name }); }); + + builder.Entity(x => + { + x.ToTable(options.TablePrefix + "Enterprises", options.Schema); + + x.Property(p => p.Name) + .IsRequired() + .HasColumnName(nameof(Enterprise.Name)) + .HasMaxLength(EnterpriseConsts.MaxNameLength); + + x.Property(p => p.EnglishName) + .HasColumnName(nameof(Enterprise.EnglishName)) + .HasMaxLength(EnterpriseConsts.MaxEnglishNameLength); + x.Property(p => p.Address) + .HasColumnName(nameof(Enterprise.Address)) + .HasMaxLength(EnterpriseConsts.MaxAddressLength); + x.Property(p => p.Logo) + .HasColumnName(nameof(Enterprise.Logo)) + .HasMaxLength(EnterpriseConsts.MaxLogoLength); + x.Property(p => p.LegalMan) + .HasColumnName(nameof(Enterprise.LegalMan)) + .HasMaxLength(EnterpriseConsts.MaxLegalManLength); + x.Property(p => p.TaxCode) + .HasColumnName(nameof(Enterprise.TaxCode)) + .HasMaxLength(EnterpriseConsts.MaxTaxCodeLength); + x.Property(p => p.OrganizationCode) + .HasColumnName(nameof(Enterprise.OrganizationCode)) + .HasMaxLength(EnterpriseConsts.MaxOrganizationCodeLength); + x.Property(p => p.RegistrationCode) + .HasColumnName(nameof(Enterprise.RegistrationCode)) + .HasMaxLength(EnterpriseConsts.MaxRegistrationCodeLength); + + x.ConfigureByConvention(); + }); } public static EntityTypeBuilder ConfigureRoute( diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs index 2321e91ac..a0114b3f9 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs @@ -1,57 +1,57 @@ -using LINGYUN.Platform.Datas; -using LINGYUN.Platform.Layouts; -using LINGYUN.Platform.Menus; +using LINGYUN.Platform.Datas; +using LINGYUN.Platform.Layouts; +using LINGYUN.Platform.Menus; using LINGYUN.Platform.Packages; -using Microsoft.EntityFrameworkCore; -using System.Linq; - -namespace LINGYUN.Platform.EntityFrameworkCore -{ - public static class PlatformEfCoreQueryableExtensions - { - - public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) - { - if (!include) - { - return queryable; - } - - return queryable; - } - - public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) - { - if (!include) - { - return queryable; - } - - return queryable; - } - - public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) - { - if (!include) - { - return queryable; - } - - return queryable - .AsSplitQuery() - .Include(x => x.Items); - } - - public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) - { - if (!include) - { - return queryable; - } - - return queryable - .AsSplitQuery() - .Include(x => x.Blobs); - } - } -} +using Microsoft.EntityFrameworkCore; +using System.Linq; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + public static class PlatformEfCoreQueryableExtensions + { + + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable; + } + + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable; + } + + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable + .AsSplitQuery() + .Include(x => x.Items); + } + + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable + .AsSplitQuery() + .Include(x => x.Blobs); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs index 8f94a1f62..ec0307a11 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs @@ -1,32 +1,34 @@ -using LINGYUN.Platform.Datas; -using LINGYUN.Platform.Layouts; -using LINGYUN.Platform.Menus; +using LINGYUN.Platform.Datas; +using LINGYUN.Platform.Layouts; +using LINGYUN.Platform.Menus; using LINGYUN.Platform.Packages; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.Modularity; - -namespace LINGYUN.Platform.EntityFrameworkCore -{ - [DependsOn( - typeof(PlatformDomainModule), - typeof(AbpEntityFrameworkCoreModule))] - public class PlatformEntityFrameworkCoreModule : AbpModule - { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAbpDbContext(options => - { - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); +using LINGYUN.Platform.Portal; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [DependsOn( + typeof(PlatformDomainModule), + typeof(AbpEntityFrameworkCoreModule))] + public class PlatformEntityFrameworkCoreModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - options.AddRepository(); - - options.AddDefaultRepositories(includeAllEntities: true); - }); - } - } -} + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + options.AddRepository(); + + options.AddDefaultRepositories(includeAllEntities: true); + }); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs new file mode 100644 index 000000000..035d8eaeb --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs @@ -0,0 +1,40 @@ +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.Portal; +public class EfCoreEnterpriseRepository : EfCoreRepository, IEnterpriseRepository +{ + public EfCoreEnterpriseRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async virtual Task GetEnterpriseInTenantAsync( + Guid id, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.Id == id) + .Select(x => x.TenantId) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task> GetEnterprisesInTenantListAsync( + int maxResultCount = 10, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.TenantId.HasValue) + .Take(maxResultCount) + .OrderByDescending(x => x.CreationTime) + .ToListAsync(GetCancellationToken(cancellationToken)); + } +} diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs index 809d9cfad..df1abe968 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs @@ -11,12 +11,14 @@ using LINGYUN.Abp.Identity.OrganizaztionUnits; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.OpenIddict.LinkUser; +using LINGYUN.Abp.OpenIddict.Portal; using LINGYUN.Abp.OpenIddict.Sms; using LINGYUN.Abp.OpenIddict.WeChat; using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.Sms.Aliyun; +using LINGYUN.Platform.EntityFrameworkCore; using LY.MicroService.AuthServer.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -58,9 +60,11 @@ namespace LY.MicroService.AuthServer; typeof(AbpOpenIddictSmsModule), typeof(AbpOpenIddictWeChatModule), typeof(AbpOpenIddictLinkUserModule), + typeof(AbpOpenIddictPortalModule), typeof(AbpAuthenticationQQModule), typeof(AbpAuthenticationWeChatModule), typeof(AbpIdentityOrganizaztionUnitsModule), + typeof(PlatformEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementDomainIdentityModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), diff --git a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj index e181ad8df..8eaa7f60a 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj @@ -59,8 +59,10 @@ + + diff --git a/aspnet-core/services/LY.MicroService.AuthServer/appsettings.Development.json b/aspnet-core/services/LY.MicroService.AuthServer/appsettings.Development.json index de3361ed3..90972661a 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.AuthServer/appsettings.Development.json @@ -33,7 +33,8 @@ "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456", "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AppPlatform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" }, "CAP": { "EventBus": { diff --git a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs index 8d454d555..f938071f4 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs @@ -12,12 +12,14 @@ using LINGYUN.Abp.Identity.EntityFrameworkCore; using LINGYUN.Abp.Identity.OrganizaztionUnits; using LINGYUN.Abp.IdentityServer; using LINGYUN.Abp.IdentityServer.EntityFrameworkCore; +using LINGYUN.Abp.IdentityServer.Portal; using LINGYUN.Abp.Localization.CultureMap; 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.Sms.Aliyun; +using LINGYUN.Platform.EntityFrameworkCore; using LY.MicroService.IdentityServer.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -57,9 +59,11 @@ namespace LY.MicroService.IdentityServer; // typeof(AbpIdentityHttpApiModule), typeof(AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpIdentityServerSmsValidatorModule), + typeof(AbpIdentityServerPortalModule), typeof(AbpAuthenticationWeChatModule), typeof(AbpAuthenticationQQModule), typeof(AbpIdentityOrganizaztionUnitsModule), + typeof(PlatformEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementDomainIdentityModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), diff --git a/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj b/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj index 0fd004f62..21705af96 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj +++ b/aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj @@ -54,6 +54,7 @@ + @@ -61,6 +62,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json b/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json index f4e522891..067a7e2c4 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json @@ -26,13 +26,15 @@ } }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", - "AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", - "AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456", - "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + "Default": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpIdentity": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AppPlatform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" }, "CAP": { "EventBus": { @@ -44,7 +46,7 @@ }, "MySql": { "TableNamePrefix": "auth", - "ConnectionString": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456" + "ConnectionString": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456" }, "RabbitMQ": { "HostName": "127.0.0.1",