ECL142 7 месяцев назад
Родитель
Сommit
3ea1304396
100 измененных файлов с 6566 добавлено и 0 удалено
  1. 0 0
      README.md
  2. 4 0
      src/ECL142.BasicAuth/.editorconfig
  3. 28 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IAccountAppService.cs
  4. 17 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IAuthAppService.cs
  5. 35 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IPermissionAppService.cs
  6. 56 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IRoleAppService.cs
  7. 43 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IUserAppService.cs
  8. 24 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Common/PageRequestDto.cs
  9. 29 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Common/PageResponseDto.cs
  10. 28 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Accounts/AccountDto.cs
  11. 62 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Accounts/AccountPermissionsDto.cs
  12. 23 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Accounts/AccountUpdatePasswordDto.cs
  13. 21 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Auths/AuthLoginDto.cs
  14. 76 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Permissions/PermissionCreateDto.cs
  15. 80 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Permissions/PermissionDto.cs
  16. 81 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Permissions/PermissionUpdateDto.cs
  17. 30 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleCreateDto.cs
  18. 41 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleDto.cs
  19. 25 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleGetPermissionDto.cs
  20. 15 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RolePageRequestDto.cs
  21. 14 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RolePageResponseDto.cs
  22. 19 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleSavePermissionDto.cs
  23. 35 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleUpdateDto.cs
  24. 43 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserCreateDto.cs
  25. 109 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserDto.cs
  26. 15 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserPageRequestDto.cs
  27. 15 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserPageResponseDto.cs
  28. 46 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserUpdateDto.cs
  29. 18 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/ECL142.BasicAuth.Application.Contracts.csproj
  30. 18 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Base/BaseAppService.cs
  31. 15 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Base/IBaseAppService.cs
  32. 24 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/AccountAppService.cs
  33. 87 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/AuthAppService.cs
  34. 29 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/PermissionAppService.cs
  35. 44 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/RoleAppService.cs
  36. 41 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/UserAppService.cs
  37. 96 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Auth/JwtBearerSetting.cs
  38. 89 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/DependencyInjection/ServicerCollectionExtensions.cs
  39. 19 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/ECL142.BasicAuth.Application.csproj
  40. 106 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Helpers/AppSettingsHelper.cs
  41. 28 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/MappingProfile.cs
  42. 39 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Session/EleSession.cs
  43. 24 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Session/IEleSession.cs
  44. 18 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Core/Check.cs
  45. 32 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Core/CollectionExtensions.cs
  46. 13 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Core/ECL142.BasicAuth.Core.csproj
  47. 28 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Core/Exceptions/BusinessException.cs
  48. 9 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Core/Exceptions/IBusinessException.cs
  49. 9 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/ECL142.BasicAuth.Domain.Shared.csproj
  50. 53 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/PermissionApiMethod.cs
  51. 17 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/PermissionStatus.cs
  52. 23 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/PermissionType.cs
  53. 17 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/RoleStatus.cs
  54. 17 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/UserStatus.cs
  55. 53 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/DependencyInjection/ServiceCollectionExtensions.cs
  56. 19 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/ECL142.BasicAuth.Domain.csproj
  57. 23 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/AggregateRoot.cs
  58. 29 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/AuditedAggregateRoot.cs
  59. 23 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/CreationAuditedAggregateRoot.cs
  60. 25 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/CreationAuditedEntity.cs
  61. 39 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/Entity.cs
  62. 134 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/ElePermission.cs
  63. 104 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleRole.cs
  64. 50 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleRoleClaim.cs
  65. 29 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleRolePermission.cs
  66. 332 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUser.cs
  67. 48 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserClaim.cs
  68. 62 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserLogin.cs
  69. 37 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserRole.cs
  70. 57 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserToken.cs
  71. 12 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/IDomainService.cs
  72. 25 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/RoleManager.cs
  73. 211 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/RoleStore.cs
  74. 43 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/UserManager.cs
  75. 346 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/UserStore.cs
  76. 144 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/IBasicRepository.cs
  77. 15 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/IRepository.cs
  78. 17 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/Identity/IPermissionRepository.cs
  79. 22 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/Identity/IRoleRepository.cs
  80. 39 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/Identity/IUserRepository.cs
  81. 25 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations.csproj
  82. 6 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations.http
  83. 809 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Migrations/20240413234821_InitDB.Designer.cs
  84. 387 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Migrations/20240413234821_InitDB.cs
  85. 806 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Migrations/ApplicationDbContextModelSnapshot.cs
  86. 30 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Program.cs
  87. 31 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Properties/launchSettings.json
  88. 8 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/appsettings.Development.json
  89. 15 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/appsettings.json
  90. 11 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/DependencyInjection/DbType.cs
  91. 81 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/DependencyInjection/ServiceCollectionExtensions.cs
  92. 19 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/ECL142.BasicAuth.EntityFrameworkCore.csproj
  93. 282 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/ApplicationDbContext.cs
  94. 84 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/EfCoreRepository.cs
  95. 11 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/Identity/EFCorePermissionRepository.cs
  96. 16 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/Identity/EFCoreRoleRepository.cs
  97. 26 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/Identity/EFCoreUserRepository.cs
  98. 33 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.WebAPI/Controllers/WeatherForecastController.cs
  99. 21 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.WebAPI/ECL142.BasicAuth.WebAPI.csproj
  100. 0 0
      src/ECL142.BasicAuth/ECL142.BasicAuth.WebAPI/ECL142.BasicAuth.WebAPI.http

+ 4 - 0
src/ECL142.BasicAuth/.editorconfig

@@ -0,0 +1,4 @@
+[*.cs]
+
+# CS8601: 引用类型赋值可能为 null。
+dotnet_diagnostic.CS8601.severity = silent

+ 28 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IAccountAppService.cs

@@ -0,0 +1,28 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts;
+
+namespace ECL142.BasicAuth.Application.Contracts.AppService.Identity
+{
+    /// <summary>
+    /// 账号应用接口
+    /// </summary>
+    public interface IAccountAppService
+    {
+        /// <summary>
+        /// 获取当前登录用户的账号信息
+        /// </summary>
+        /// <returns></returns>
+        public Task<AccountDto> GetAsync();
+
+        /// <summary>
+        /// 获取当前登录用户的权限列表
+        /// </summary>
+        /// <returns></returns>
+        public Task<List<AccountPermissionsDto>> GetPermissionsAsync();
+
+        /// <summary>
+        /// 修改密码
+        /// </summary>
+        /// <param name="accountUpdatePassword"></param>
+        public Task UpdatePasswordAnsync(AccountUpdatePasswordDto accountUpdatePassword);
+    }
+}

+ 17 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IAuthAppService.cs

@@ -0,0 +1,17 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Auths;
+
+namespace ECL142.BasicAuth.Application.Contracts.AppService.Identity
+{
+    /// <summary>
+    /// 认证应用接口
+    /// </summary>
+    public interface IAuthAppService
+    {
+        /// <summary>
+        /// 登录
+        /// </summary>
+        /// <param name="authLoginDto"></param>
+        /// <returns></returns>
+        public Task<string> LoginAsync(AuthLoginDto authLoginDto);
+    }
+}

+ 35 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IPermissionAppService.cs

@@ -0,0 +1,35 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Permissions;
+
+namespace ECL142.BasicAuth.Application.Contracts.AppService.Identity
+{
+    /// <summary>
+    /// 权限应用接口
+    /// </summary>
+    public interface IPermissionAppService
+    {
+        /// <summary>
+        /// 获取所有权限
+        /// </summary>
+        /// <returns></returns>
+        public Task<List<PermissionDto>> GetAllAsync();
+
+        /// <summary>
+        /// 添加权限
+        /// </summary>
+        /// <param name="permissionCreateDto"></param>
+        public Task<PermissionDto> InsertAsync(PermissionCreateDto permissionCreateDto);
+
+        /// <summary>
+        /// 修改权限
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="permissionUpdateDto"></param>
+        public Task<PermissionDto> UpdateAsync(Guid id, PermissionUpdateDto permissionUpdateDto);
+
+        /// <summary>
+        /// 删除权限
+        /// </summary>
+        /// <param name="id"></param>
+        public Task DeleteAsync(Guid id);
+    }
+}

+ 56 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IRoleAppService.cs

@@ -0,0 +1,56 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles;
+
+namespace ECL142.BasicAuth.Application.Contracts.AppService.Identity
+{
+    /// <summary>
+    /// 角色应用接口
+    /// </summary>
+    public interface IRoleAppService
+    {
+        /// <summary>
+        /// 根据角色名称,分页返回角色列表
+        /// </summary>
+        /// <param name="rolePageRequestDto"></param>
+        /// <returns></returns>
+        public Task<RolePageResponseDto> GetPagedListAsync(RolePageRequestDto rolePageRequestDto);
+
+        /// <summary>
+        /// 获取所有角色列表
+        /// </summary>
+        /// <returns></returns>
+        public Task<List<RoleDto>> GetAllAsync();
+
+        /// <summary>
+        /// 保存角色的权限列表
+        /// </summary>
+        /// <param name="id">角色Id</param>
+        /// <param name="roleSavePermissionDto">以,分割权限Id</param>
+        /// <returns></returns>
+        public Task SavePermissionsAsync(Guid id, RoleSavePermissionDto roleSavePermissionDto);
+
+        /// <summary>
+        /// 获取角色的权限列表
+        /// </summary>
+        /// <returns></returns>
+        public Task<List<RoleGetPermissionDto>> GetPermissionsAsync(Guid id);
+
+        /// <summary>
+        /// 添加角色
+        /// </summary>
+        /// <param name="roleCreateDto"></param>
+        public Task<RoleDto> InsertAsync(RoleCreateDto roleCreateDto);
+
+        /// <summary>
+        /// 修改角色
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="roleUpdateDto"></param>
+        public Task<RoleDto> UpdateAsync(Guid id, RoleUpdateDto roleUpdateDto);
+
+        /// <summary>
+        /// 删除角色
+        /// </summary>
+        /// <param name="id"></param>
+        public Task DeleteAsync(Guid id);
+    }
+}

+ 43 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/AppService/Identity/IUserAppService.cs

@@ -0,0 +1,43 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users;
+
+namespace ECL142.BasicAuth.Application.Contracts.AppService.Identity
+{
+    /// <summary>
+    /// 用户应用接口
+    /// </summary>
+    public interface IUserAppService
+    {
+        /// <summary>
+        /// 获取用户
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public Task<UserDto> GetAsync(Guid id);
+
+        /// <summary>
+        /// 根据用户名搜索,分页返回用户列表
+        /// </summary>
+        /// <param name="userPageRequestDto"></param>
+        /// <returns></returns>
+        public Task<UserPageResponseDto> GetPagedListAsync(UserPageRequestDto userPageRequestDto);
+
+        /// <summary>
+        /// 添加用户
+        /// </summary>
+        /// <param name="userCreateDto"></param>
+        public Task<UserDto> InsertAsync(UserCreateDto userCreateDto);
+
+        /// <summary>
+        /// 修改用户
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="userUpdateDto"></param>
+        public Task<UserDto> UpdateAsync(Guid id, UserUpdateDto userUpdateDto);
+
+        /// <summary>
+        /// 删除用户
+        /// </summary>
+        /// <param name="id"></param>
+        public Task DeleteAsync(Guid id);
+    }
+}

+ 24 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Common/PageRequestDto.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Common
+{
+    /// <summary>
+    /// 分页请求对象
+    /// </summary>
+    public class PageRequestDto
+    {
+        /// <summary>
+        /// 每页记录数量
+        /// </summary>
+        public int PrePage { get; set; }
+
+        /// <summary>
+        /// 当前页码
+        /// </summary>
+        public int Page { get; set; }
+    }
+}

+ 29 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Common/PageResponseDto.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Common
+{
+    /// <summary>
+    /// 分页响应实体
+    /// </summary>
+    public class PageResponseDto
+    {
+        /// <summary>
+        /// 每页记录数量
+        /// </summary>
+        public int PrePage { get; set; }
+
+        /// <summary>
+        /// 当前页码
+        /// </summary>
+        public int Page { get; set; }
+
+        /// <summary>
+        /// 总数
+        /// </summary>
+        public long Total { get; set; }
+    }
+}

+ 28 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Accounts/AccountDto.cs

@@ -0,0 +1,28 @@
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts
+{
+    /// <summary>
+    /// 登录账号信息
+    /// </summary>
+    public class AccountDto
+    {
+        /// <summary>
+        /// 角色列表
+        /// </summary>
+        public string[] Roles { get; set; }
+
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 头像
+        /// </summary>
+        public string Avatar { get; set; }
+
+        /// <summary>
+        /// 介绍
+        /// </summary>
+        public string Introduction { get; set; }
+    }
+}

+ 62 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Accounts/AccountPermissionsDto.cs

@@ -0,0 +1,62 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts
+{
+    /// <summary>
+    /// 登录账号的权限
+    /// </summary>
+    public class AccountPermissionsDto
+    {
+        public Guid Id { get; set; }
+
+        /// <summary>
+        /// 权限名称
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 权限编码
+        /// </summary>
+        public string Code { get; set; }
+
+        /// <summary>
+        /// Url地址
+        /// </summary>
+        public string Url { get; set; }
+
+        /// <summary>
+        /// Vue页面组件
+        /// </summary>
+        public string Component { get; set; }
+
+        /// <summary>
+        /// 图标
+        /// </summary>
+        public string Icon { get; set; }
+
+        /// <summary>
+        /// 菜单类型:菜单权限、元素权限、Api权限、数据权限
+        /// </summary>
+        public PermissionType PermissionType { get; set; }
+
+        /// <summary>
+        /// API方法
+        /// </summary>
+        public string ApiMethod { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 父菜单Id
+        /// </summary>
+        public Guid? ParentId { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+}

+ 23 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Accounts/AccountUpdatePasswordDto.cs

@@ -0,0 +1,23 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts
+{ /// <summary>
+  /// 登录账号密码修改
+  /// </summary>
+    public class AccountUpdatePasswordDto
+    {
+        /// <summary>
+        /// 原本密码
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 6)]
+        public string OldPassword { get; set; }
+
+        /// <summary>
+        /// 新密码
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 6)]
+        public string NewPassword { get; set; }
+    }
+}

+ 21 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Auths/AuthLoginDto.cs

@@ -0,0 +1,21 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Auths
+{
+    public class AuthLoginDto
+    {
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 3)]
+        public string UserName { get; set; }
+
+        /// <summary>
+        /// 密码
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 6)]
+        public string Password { get; set; }
+    }
+}

+ 76 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Permissions/PermissionCreateDto.cs

@@ -0,0 +1,76 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Permissions
+{
+    /// <summary>
+    /// 创建权限对象
+    /// </summary>
+    public class PermissionCreateDto
+    {
+        /// <summary>
+        /// 权限名称
+        /// </summary>
+        [Required]
+        [MaxLength(20)]
+        public string Name { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 权限编码
+        /// </summary>
+        [Required]
+        [MaxLength(100)]
+        public string Code { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Url地址
+        /// </summary>
+        [MaxLength(200)]
+        public string Url { get; set; }
+
+        /// <summary>
+        /// Vue页面组件
+        /// </summary>
+        [MaxLength(200)]
+        public string Component { get; set; }
+
+        /// <summary>
+        /// 图标
+        /// </summary>
+        [MaxLength(100)]
+        public string Icon { get; set; }
+
+        /// <summary>
+        /// 菜单类型:菜单权限、元素权限、Api权限、数据权限
+        /// </summary>
+        public PermissionType PermissionType { get; set; }
+
+        /// <summary>
+        /// API方法
+        /// </summary>
+        [MaxLength(50)]
+        public string ApiMethod { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 父菜单Id
+        /// </summary>
+        public Guid? ParentId { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public PermissionStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string Remark { get; set; }
+    }
+}

+ 80 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Permissions/PermissionDto.cs

@@ -0,0 +1,80 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Permissions
+{
+    /// <summary>
+    /// 菜单权限信息
+    /// </summary>
+    public class PermissionDto
+    {
+        public Guid Id { get; set; }
+
+        public Guid? CreatorId { get; set; }
+
+        public DateTime CreationTime { get; set; }
+
+        public DateTime? LastModificationTime { get; set; }
+        public Guid? LastModifierId { get; set; }
+
+        /// <summary>
+        /// 权限名称
+        /// </summary>
+        public string Name { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 权限编码
+        /// </summary>
+        public string Code { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Url地址
+        /// </summary>
+        public string Url { get; set; }
+
+        /// <summary>
+        /// Vue页面组件
+        /// </summary>
+        public string Component { get; set; }
+
+        /// <summary>
+        /// 图标
+        /// </summary>
+        public string Icon { get; set; }
+
+        /// <summary>
+        /// 菜单类型:菜单权限、元素权限、Api权限、数据权限
+        /// </summary>
+        public PermissionType PermissionType { get; set; }
+
+        /// <summary>
+        /// API方法
+        /// </summary>
+        public string ApiMethod { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 父菜单Id
+        /// </summary>
+        public Guid? ParentId { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public PermissionStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+}

+ 81 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Permissions/PermissionUpdateDto.cs

@@ -0,0 +1,81 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Permissions
+{
+    /// <summary>
+    /// 更新权限信息
+    /// </summary>
+    public class PermissionUpdateDto
+    {
+        /// <summary>
+        /// 权限名称
+        /// </summary>
+        [Required]
+        [MaxLength(20)]
+        public string Name { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 权限编码
+        /// </summary>
+        [Required]
+        [MaxLength(100)]
+        public string Code { get; set; } = string.Empty;
+
+        /// <summary>
+        /// Url地址
+        /// </summary>
+        [MaxLength(200)]
+        public string Url { get; set; }
+
+        /// <summary>
+        /// Vue页面组件
+        /// </summary>
+        [MaxLength(200)]
+        public string Component { get; set; }
+
+        /// <summary>
+        /// 图标
+        /// </summary>
+        [MaxLength(100)]
+        public string Icon { get; set; }
+
+        /// <summary>
+        /// 菜单类型:菜单权限、元素权限、Api权限、数据权限
+        /// </summary>
+        public PermissionType PermissionType { get; set; }
+
+        /// <summary>
+        /// API方法
+        /// </summary>
+        [MaxLength(50)]
+        public string ApiMethod { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 父菜单Id
+        /// </summary>
+        public Guid? ParentId { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public PermissionStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string Remark { get; set; }
+    }
+}

+ 30 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleCreateDto.cs

@@ -0,0 +1,30 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{
+    /// <summary>
+    /// 角色创建
+    /// </summary>
+    public class RoleCreateDto
+    {
+        /// <summary>
+        /// 角色名称
+        /// </summary>
+        [Required]
+        [MaxLength(50)]
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public RoleStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string Remark { get; set; }
+    }
+}

+ 41 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleDto.cs

@@ -0,0 +1,41 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{
+    /// <summary>
+    /// 角色信息
+    /// </summary>
+    public class RoleDto
+    {
+        public Guid? Id { get; set; }
+
+        /// <summary>
+        /// 创建者
+        /// </summary>
+        public string Creator { get; set; }
+
+        public DateTime CreationTime { get; set; }
+
+        public DateTime LastModificationTime { get; set; }
+
+        /// <summary>
+        /// 角色名称
+        /// </summary>
+        [Required]
+        [MaxLength(50)]
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public RoleStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string Remark { get; set; }
+    }
+}

+ 25 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleGetPermissionDto.cs

@@ -0,0 +1,25 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{
+    /// <summary>
+    /// 角色的权限列表
+    /// </summary>
+    public class RoleGetPermissionDto
+    {
+        /// <summary>
+        /// 权限Id列表
+        /// </summary>
+        public Guid Id { get; set; }
+
+        /// <summary>
+        /// 菜单类型:菜单权限、元素权限、Api权限、数据权限
+        /// </summary>
+        public PermissionType PermissionType { get; set; }
+
+        /// <summary>
+        /// 父菜单Id
+        /// </summary>
+        public Guid? ParentId { get; set; }
+    }
+}

+ 15 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RolePageRequestDto.cs

@@ -0,0 +1,15 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Common;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{
+    /// <summary>
+    /// 角色翻页查询
+    /// </summary>
+    public class RolePageRequestDto : PageRequestDto
+    {
+        /// <summary>
+        /// 用户昵称
+        /// </summary>
+        public string Name { get; set; }
+    }
+}

+ 14 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RolePageResponseDto.cs

@@ -0,0 +1,14 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Common;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{  /// <summary>
+   /// 角色翻页响应对象
+   /// </summary>
+    public class RolePageResponseDto : PageResponseDto
+    {
+        /// <summary>
+        /// 角色列表
+        /// </summary>
+        public List<RoleDto> Roles { get; set; }
+    }
+}

+ 19 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleSavePermissionDto.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{
+    /// <summary>
+    /// 角色分配权限
+    /// </summary>
+    public class RoleSavePermissionDto
+    {
+        /// <summary>
+        /// 权限Id列表
+        /// </summary>
+        public List<Guid> PermissionIds { get; set; }
+    }
+}

+ 35 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Roles/RoleUpdateDto.cs

@@ -0,0 +1,35 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles
+{
+    /// <summary>
+    /// 角色更新
+    /// </summary>
+    public class RoleUpdateDto
+    {
+        /// <summary>
+        /// 角色名称
+        /// </summary>
+        [Required]
+        [MaxLength(50)]
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public RoleStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string mark { get; set; }
+    }
+}

+ 43 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserCreateDto.cs

@@ -0,0 +1,43 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users
+{
+    public class UserCreateDto
+    {
+        /// <summary>
+        /// 密码
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 6)]
+        public string Password { get; set; }
+
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 3)]
+        public string UserName { get; set; }
+
+        public string Email { get; set; }
+
+        /// <summary>
+        /// 全名:姓名
+        /// </summary>
+        [MaxLength(20)]
+        public string FullName { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        [Required]
+        public UserStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string Remark { get; set; }
+    }
+}

+ 109 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserDto.cs

@@ -0,0 +1,109 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users
+{
+    public class UserDto
+    {
+        public Guid Id { get; set; }
+
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public DateTime CreationTime { get; set; }
+
+        /// <summary>
+        /// 创建者
+        /// </summary>
+        public string Creator { get; set; }
+
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        public string UserName { get; set; }
+
+        /// <summary>
+        /// 标准化用户名
+        /// </summary>
+        public string NormalizedUserName { get; set; }
+
+        /// <summary>
+        /// Email
+        /// </summary>
+        public string Email { get; set; }
+
+        /// <summary>
+        /// 标准化Email
+        /// </summary>
+        public string NormalizedEmail { get; set; }
+
+        /// <summary>
+        /// 邮箱是否确认
+        /// </summary>
+        public bool EmailConfirmed { get; set; }
+
+        /// <summary>
+        /// 密码哈希
+        /// </summary>
+        public string PasswordHash { get; set; }
+
+        /// <summary>
+        /// 一个随机值,每当用户凭据更改时(密码更改、登录删除),该值都必须更改
+        /// </summary>
+        public string SecurityStamp { get; set; }
+
+        /// <summary>
+        /// 一个随机值,每当用户被持久化到存储时,该值必须更改
+        /// </summary>
+        public string ConcurrencyStamp { get; set; }
+
+        /// <summary>
+        /// 获取或设置用户的电话号码。
+        /// </summary>
+        public string PhoneNumber { get; set; }
+
+        /// <summary>
+        /// 获取或设置一个标志,该标志指示用户是否已确认其电话地址。
+        /// </summary>
+        public bool PhoneNumberConfirmed { get; set; }
+
+        /// <summary>
+        /// 获取或设置一个标志,该标志指示是否为此用户启用了双因素身份验证。
+        /// </summary>
+        public bool TwoFactorEnabled { get; set; }
+
+        /// <summary>
+        /// 获取或设置任何用户锁定结束的日期和时间(以UTC为单位)。
+        /// </summary>
+        public DateTimeOffset? LockoutEnd { get; set; }
+
+        /// <summary>
+        /// 获取或设置一个标志,该标志指示用户是否可以被锁定。
+        /// </summary>
+        public bool LockoutEnabled { get; set; }
+
+        /// <summary>
+        /// 获取或设置当前用户登录尝试失败的次数。
+        /// </summary>
+        public int AccessFailedCount { get; set; }
+
+        /// <summary>
+        /// 全名:姓名
+        /// </summary>
+        public string FullName { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public UserStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+        /// <summary>
+        /// 角色列表
+        /// </summary>
+        public ICollection<string> Roles { get; set; }
+    }
+}

+ 15 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserPageRequestDto.cs

@@ -0,0 +1,15 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Common;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users
+{
+    /// <summary>
+    /// 用户翻页查询
+    /// </summary>
+    public class UserPageRequestDto : PageRequestDto
+    {
+        /// <summary>
+        /// 用户昵称
+        /// </summary>
+        public string UserName { get; set; }
+    }
+}

+ 15 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserPageResponseDto.cs

@@ -0,0 +1,15 @@
+using ECL142.BasicAuth.Application.Contracts.Dto.Common;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users
+{
+    /// <summary>
+    /// 用户翻页响应对象
+    /// </summary>
+    public class UserPageResponseDto : PageResponseDto
+    {
+        /// <summary>
+        /// 用户列表
+        /// </summary>
+        public List<UserDto> Users { get; set; }
+    }
+}

+ 46 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/Dto/Identity/Users/UserUpdateDto.cs

@@ -0,0 +1,46 @@
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System.ComponentModel.DataAnnotations;
+
+namespace ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users
+{
+    public class UserUpdateDto
+    {
+        /// <summary>
+        /// 密码
+        /// </summary>
+        [StringLength(20)]
+        public string Password { get; set; }
+
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        [Required]
+        [StringLength(20, MinimumLength = 3)]
+        public string UserName { get; set; }
+
+        /// <summary>
+        /// 全名:姓名
+        /// </summary>
+        [MaxLength(20)]
+        public string FullName { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        [Required]
+        public UserStatus Status { get; set; }
+
+        /// <summary>
+        /// 角色列表
+        /// </summary>
+        [Required]
+        public List<string> RoleNames { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [MaxLength(500)]
+        public string Remark { get; set; }
+    }
+}

+ 18 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application.Contracts/ECL142.BasicAuth.Application.Contracts.csproj

@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>disable</Nullable>
+    <GenerateDocumentationFile>True</GenerateDocumentationFile>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Include="..\.editorconfig" Link=".editorconfig" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\ECL142.BasicAuth.Domain.Shared\ECL142.BasicAuth.Domain.Shared.csproj" />
+  </ItemGroup>
+
+</Project>

+ 18 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Base/BaseAppService.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.AppService.Base
+{
+    /// <summary>
+    /// 应用基础服务
+    /// </summary>
+    public class BaseAppService : IBaseAppService
+    {
+        public BaseAppService()
+        {
+        }
+    }
+}

+ 15 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Base/IBaseAppService.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.AppService.Base
+{
+    /// <summary>
+    /// 应用服务基接口
+    /// </summary>
+    public interface IBaseAppService
+    {
+    }
+}

+ 24 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/AccountAppService.cs

@@ -0,0 +1,24 @@
+using ECL142.BasicAuth.Application.AppService.Base;
+using ECL142.BasicAuth.Application.Contracts.AppService.Identity;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts;
+
+namespace ECL142.BasicAuth.Application.AppService.Identity
+{
+    public class AccountAppService : BaseAppService, IAccountAppService
+    {
+        public Task<AccountDto> GetAsync()
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<AccountPermissionsDto>> GetPermissionsAsync()
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task UpdatePasswordAnsync(AccountUpdatePasswordDto accountUpdatePassword)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 87 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/AuthAppService.cs

@@ -0,0 +1,87 @@
+using ECL142.BasicAuth.Application.AppService.Base;
+using ECL142.BasicAuth.Application.Auth;
+using ECL142.BasicAuth.Application.Contracts.AppService.Identity;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Auths;
+using ECL142.BasicAuth.Core.Exceptions;
+using ECL142.BasicAuth.Domain.Manager.Identity;
+
+using Microsoft.IdentityModel.Tokens;
+
+using System.IdentityModel.Tokens.Jwt;
+
+using System.Security.Claims;
+
+using System.Text;
+
+namespace ECL142.BasicAuth.Application.AppService.Identity
+{
+    public class AuthAppService : BaseAppService, IAuthAppService
+    {
+        /// <summary>
+        /// JWT配置
+        /// </summary>
+        private readonly JwtBearerSetting _jwtBearerSetting;
+
+        /// <summary>
+        /// 用户管理器
+        /// </summary>
+        private readonly UserManager _userManager;
+
+        /// <summary>
+        /// 注入
+        /// </summary>
+        /// <param name="jwtBearerSetting"></param>
+        /// <param name="userManager"></param>
+        public AuthAppService(JwtBearerSetting jwtBearerSetting, UserManager userManager)
+        {
+            _jwtBearerSetting = jwtBearerSetting;
+            _userManager = userManager;
+        }
+
+        /// <summary>
+        /// 登录
+        /// </summary>
+        /// <param name="authLoginDto"></param>
+        /// <returns></returns>
+        /// <exception cref="BusinessException"></exception>
+        public async Task<string> LoginAsync(AuthLoginDto authLoginDto)
+        {
+            //根据用户名、密码校验
+            var user = await _userManager.FindByNameAsync(authLoginDto.UserName);
+            if (user == null)
+            {
+                throw new BusinessException("登录失败,账号或密码错误");
+            }
+
+            var succeeded = await _userManager.CheckPasswordAsync(user, authLoginDto.Password);
+            if (succeeded)
+            {
+                //定义JWT的Payload部分
+                var claims = new[]
+                {
+                    new Claim(ClaimTypes.Name, authLoginDto.UserName),
+                    new Claim(ClaimTypes.Sid, user.Id.ToString()),
+                };
+
+                //生成token
+                var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtBearerSetting.SecurityKey));
+                var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
+                var securityToken = new JwtSecurityToken(
+                    issuer: _jwtBearerSetting.Issuer,
+                    audience: _jwtBearerSetting.Audience,
+                    claims: claims,
+                    expires: DateTime.Now.AddDays(1),
+                    signingCredentials: creds);
+
+                var token = new JwtSecurityTokenHandler().WriteToken(securityToken);
+
+                //返回token
+                return token;
+            }
+            else
+            {
+                throw new BusinessException("登录失败,账号或密码错误");
+            }
+        }
+    }
+}

+ 29 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/PermissionAppService.cs

@@ -0,0 +1,29 @@
+using ECL142.BasicAuth.Application.AppService.Base;
+using ECL142.BasicAuth.Application.Contracts.AppService.Identity;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Permissions;
+
+namespace ECL142.BasicAuth.Application.AppService.Identity
+{
+    public class PermissionAppService : BaseAppService, IPermissionAppService
+    {
+        public Task DeleteAsync(Guid id)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<PermissionDto>> GetAllAsync()
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<PermissionDto> InsertAsync(PermissionCreateDto permissionCreateDto)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<PermissionDto> UpdateAsync(Guid id, PermissionUpdateDto permissionUpdateDto)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 44 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/RoleAppService.cs

@@ -0,0 +1,44 @@
+using ECL142.BasicAuth.Application.AppService.Base;
+using ECL142.BasicAuth.Application.Contracts.AppService.Identity;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles;
+
+namespace ECL142.BasicAuth.Application.AppService.Identity
+{
+    public class RoleAppService : BaseAppService, IRoleAppService
+    {
+        public Task DeleteAsync(Guid id)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<RoleDto>> GetAllAsync()
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<RolePageResponseDto> GetPagedListAsync(RolePageRequestDto rolePageRequestDto)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<RoleGetPermissionDto>> GetPermissionsAsync(Guid id)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<RoleDto> InsertAsync(RoleCreateDto roleCreateDto)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task SavePermissionsAsync(Guid id, RoleSavePermissionDto roleSavePermissionDto)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<RoleDto> UpdateAsync(Guid id, RoleUpdateDto roleUpdateDto)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 41 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/AppService/Identity/UserAppService.cs

@@ -0,0 +1,41 @@
+using ECL142.BasicAuth.Application.AppService.Base;
+using ECL142.BasicAuth.Application.Contracts.AppService.Identity;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.AppService.Identity
+{
+    public class UserAppService : BaseAppService, IUserAppService
+    {
+        public Task DeleteAsync(Guid id)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<UserDto> GetAsync(Guid id)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<UserPageResponseDto> GetPagedListAsync(UserPageRequestDto userPageRequestDto)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<UserDto> InsertAsync(UserCreateDto userCreateDto)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<UserDto> UpdateAsync(Guid id, UserUpdateDto userUpdateDto)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 96 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Auth/JwtBearerSetting.cs

@@ -0,0 +1,96 @@
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.IdentityModel.Tokens;
+
+namespace ECL142.BasicAuth.Application.Auth
+{
+    /// <summary>
+    /// JWT配置
+    /// </summary>
+    public class JwtBearerSetting
+    {
+        /// <summary>
+        /// 身份验证方案
+        /// </summary>
+        public string AuthenticateScheme { get; }
+
+        /// <summary>
+        /// 验证发行者
+        /// </summary>
+        public bool ValidateIssuer { get; }
+
+        /// <summary>
+        /// 发行者
+        /// </summary>
+        public string Issuer { get; }
+
+        /// <summary>
+        /// 验证接受者
+        /// </summary>
+        public bool ValidateAudience { get; }
+
+        /// <summary>
+        /// 接收者
+        /// </summary>
+        public string Audience { get; }
+
+        /// <summary>
+        /// 验证安全密钥
+        /// </summary>
+        public bool ValidateIssuerSigningKey { get; }
+
+        /// <summary>
+        /// 安全密钥
+        /// </summary>
+        public string SecurityKey { get; }
+
+        /// <summary>
+        /// 是否验证失效时间
+        /// </summary>
+        public bool ValidateLifetime { get; }
+
+        /// <summary>
+        /// 偏差秒数:防止客户端与服务器时间偏差
+        /// </summary>
+        public int ClockSkew { get; }
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="issuer"></param>
+        /// <param name="audience"></param>
+        /// <param name="securityKey"></param>
+        /// <param name="authenticateScheme">默认值:Bearer</param>
+        /// <param name="validateIssuer">默认值:true</param>
+        /// <param name="validateAudience">默认值:true</param>
+        /// <param name="validateIssuerSigningKey">默认值:true</param>
+        /// <param name="validateLifetime">默认值:true</param>
+        /// <param name="clockSkew">默认值:5秒</param>
+        public JwtBearerSetting(string issuer, string audience, string securityKey, string authenticateScheme = JwtBearerDefaults.AuthenticationScheme,
+            bool validateIssuer = true, bool validateAudience = true, bool validateIssuerSigningKey = true, bool validateLifetime = true, int clockSkew = 5)
+        {
+            Issuer = issuer;
+            Audience = audience;
+            SecurityKey = securityKey;
+            AuthenticateScheme = authenticateScheme;
+            ValidateIssuer = validateIssuer;
+            ValidateAudience = validateAudience;
+            ValidateIssuerSigningKey = validateIssuerSigningKey;
+            ValidateLifetime = validateLifetime;
+            ClockSkew = clockSkew;
+        }
+
+        public JwtBearerSetting(Func<JwtBearerSetting> options)
+        {
+            var x = options.Invoke();
+            Issuer = x.Issuer;
+            Audience = x.Audience;
+            SecurityKey = x.SecurityKey;
+            AuthenticateScheme = x.AuthenticateScheme;
+            ValidateIssuer = x.ValidateIssuer;
+            ValidateAudience = x.ValidateAudience;
+            ValidateIssuerSigningKey = x.ValidateIssuerSigningKey;
+            ValidateLifetime = x.ValidateLifetime;
+            ClockSkew = x.ClockSkew;
+        }
+    }
+}

+ 89 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/DependencyInjection/ServicerCollectionExtensions.cs

@@ -0,0 +1,89 @@
+using AutoMapper;
+
+using ECL142.BasicAuth.Application.AppService.Base;
+using ECL142.BasicAuth.Application.Auth;
+using ECL142.BasicAuth.Application.Session;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.IdentityModel.Tokens;
+
+using System.Text;
+
+namespace ECL142.BasicAuth.Application.DependencyInjection
+{
+    public static class ServiceCollectionExtensions
+    {
+        /// <summary>
+        /// 应用注入
+        /// </summary>
+        /// <param name="services"></param>
+        public static void AddApplication(this IServiceCollection services)
+        {
+            //Dto映射
+            IConfigurationProvider config = new MapperConfiguration(cfg =>
+            {
+                cfg.AddProfile<MappingProfile>();
+            });
+            services.AddSingleton(config);
+
+            //Session注入
+            services.AddTransient<IEleSession, EleSession>();
+            services.AddTransient<IHttpContextAccessor, HttpContextAccessor>();
+
+            //AppService注入
+            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+            foreach (var assembly in assemblies)
+            {
+                //获取继承IBaseAppService的类
+                List<Type> types = assembly.GetTypes()
+                .Where(t => t.IsClass && t.GetInterfaces().Contains(typeof(IBaseAppService)))
+                .ToList();
+
+                types.ForEach(impl =>
+                {
+                    //获取该类所继承的所有接口
+                    Type[] interfaces = impl.GetInterfaces();
+                    interfaces.ToList().ForEach(i =>
+                    {
+                        services.AddScoped(i, impl);
+                    });
+                });
+            }
+        }
+
+        /// <summary>
+        /// 添加JWT中间件
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="jwtBearerSetting"></param>
+        public static void AddJWT(this IServiceCollection services, JwtBearerSetting jwtBearerSetting)
+        {
+            services.AddAuthentication(options =>
+            {
+                options.DefaultAuthenticateScheme = jwtBearerSetting.AuthenticateScheme;
+                options.DefaultChallengeScheme = jwtBearerSetting.AuthenticateScheme;
+                options.DefaultScheme = jwtBearerSetting.AuthenticateScheme;
+            }).AddJwtBearer(options =>
+            {
+                options.TokenValidationParameters = new TokenValidationParameters
+                {
+                    ValidateIssuer = jwtBearerSetting.ValidateIssuer,//是否验证Issuer
+                    ValidIssuer = jwtBearerSetting.Issuer,//Issuer
+
+                    ValidateAudience = jwtBearerSetting.ValidateAudience,//是否验证Audience
+                    ValidAudience = jwtBearerSetting.Audience,//Audience
+
+                    ValidateIssuerSigningKey = jwtBearerSetting.ValidateIssuerSigningKey,//是否验证SecurityKey
+                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtBearerSetting.SecurityKey)),//拿到SecurityKey
+
+                    ValidateLifetime = jwtBearerSetting.ValidateLifetime,//是否验证失效时间
+                    ClockSkew = TimeSpan.FromSeconds(jwtBearerSetting.ClockSkew)//偏差秒数:防止客户端与服务器时间偏差
+                };
+            });
+
+            //注入JWT配置
+            services.AddSingleton(jwtBearerSetting);
+        }
+    }
+}

+ 19 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/ECL142.BasicAuth.Application.csproj

@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="AutoMapper" Version="13.0.1" />
+    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\ECL142.BasicAuth.Application.Contracts\ECL142.BasicAuth.Application.Contracts.csproj" />
+    <ProjectReference Include="..\ECL142.BasicAuth.Domain\ECL142.BasicAuth.Domain.csproj" />
+  </ItemGroup>
+
+</Project>

+ 106 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Helpers/AppSettingsHelper.cs

@@ -0,0 +1,106 @@
+using Microsoft.Extensions.Configuration;
+
+namespace ECL142.BasicAuth.Application.Helpers
+{
+    /// <summary>
+    /// appsettings.json帮助类
+    /// </summary>
+    public class AppSettingsHelper
+    {
+        #region 注入参数
+
+        /// <summary>
+        /// 配置文件
+        /// </summary>
+        private static IConfiguration? _config;
+
+        #endregion 注入参数
+
+        #region 构造函数
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public AppSettingsHelper()
+        {
+            _config = new ConfigurationBuilder()
+                    .AddJsonFile("appsettings.json", true, reloadOnChange: true)
+                    .Build();
+        }
+
+        #endregion 构造函数
+
+        #region 静态方法
+
+        /// <summary>
+        /// 读取指定节点信息
+        /// </summary>
+        /// <param name="sessions">节点名称</param>
+        /// <returns></returns>
+        public static string ReadString(params string[] sessions)
+        {
+            try
+            {
+                if (_config != null && sessions.Any())
+                {
+                    string? str = _config[string.Join(":", sessions)];
+                    if (!string.IsNullOrEmpty(str))
+                    {
+                        return str;
+                    }
+                }
+            }
+            catch
+            {
+                return string.Empty;
+            }
+            return string.Empty;
+        }
+
+        /// <summary>
+        /// 读取实体信息
+        /// </summary>
+        /// <param name="sessions">节点名称</param>
+        /// <returns></returns>
+        public static T ReadObject<T>(params string[] sessions) where T : class, new()
+        {
+            T data = new();
+            try
+            {
+                if (_config != null && sessions.Any())
+                {
+                    _config.Bind(string.Join(":", sessions), data);
+                }
+            }
+            catch
+            {
+                return data;
+            }
+            return data;
+        }
+
+        /// <summary>
+        /// 读取实体集合信息
+        /// </summary>
+        /// <param name="sessions">节点名称</param>
+        /// <returns></returns>
+        public static List<T> ReadList<T>(params string[] sessions) where T : class
+        {
+            List<T> list = new();
+            try
+            {
+                if (_config != null && sessions.Any())
+                {
+                    _config.Bind(string.Join(":", sessions), list);
+                }
+            }
+            catch
+            {
+                return list;
+            }
+            return list;
+        }
+
+        #endregion 静态方法
+    }
+}

+ 28 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/MappingProfile.cs

@@ -0,0 +1,28 @@
+using AutoMapper;
+
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Accounts;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Permissions;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Roles;
+using ECL142.BasicAuth.Application.Contracts.Dto.Identity.Users;
+using ECL142.BasicAuth.Domain.Entities.Identity;
+
+namespace ECL142.BasicAuth.Application
+{
+    public class MappingProfile : Profile
+    {
+        public MappingProfile()
+        {
+            //用户
+            CreateMap<EleUser, UserDto>();
+
+            //角色
+            CreateMap<EleRole, RoleDto>();
+
+            //权限
+            CreateMap<ElePermission, PermissionDto>();
+            CreateMap<ElePermission, AccountPermissionsDto>();
+            CreateMap<EleRolePermission, RoleSavePermissionDto>();
+            CreateMap<ElePermission, RoleGetPermissionDto>();
+        }
+    }
+}

+ 39 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Session/EleSession.cs

@@ -0,0 +1,39 @@
+using Microsoft.AspNetCore.Http;
+
+using System.Security.Claims;
+
+namespace ECL142.BasicAuth.Application.Session
+{
+    public class EleSession : IEleSession
+    {
+        private readonly IHttpContextAccessor _httpContextAccessor;
+
+        public EleSession(IHttpContextAccessor httpContextAccessor)
+        {
+            _httpContextAccessor = httpContextAccessor;
+        }
+
+        /// <summary>
+        /// 登录用户名
+        /// </summary>
+        public string UserName
+        {
+            get
+            {
+                return _httpContextAccessor.HttpContext?.User.Identity?.Name ?? string.Empty;
+            }
+        }
+
+        /// <summary>
+        /// 登录Id
+        /// </summary>
+        public Guid UserId
+        {
+            get
+            {
+                var id = _httpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.Sid) ?? string.Empty;
+                return Guid.Parse(id);
+            }
+        }
+    }
+}

+ 24 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Application/Session/IEleSession.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Application.Session
+{
+    /// <summary>
+    /// 自定义会话
+    /// </summary>
+    public interface IEleSession
+    {
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        public string UserName { get; }
+
+        /// <summary>
+        /// 用户登录Id
+        /// </summary>
+        public Guid UserId { get; }
+    }
+}

+ 18 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Core/Check.cs

@@ -0,0 +1,18 @@
+namespace ECL142.BasicAuth.Core
+{
+    /// <summary>
+    /// 自定义检查类
+    /// </summary>
+    public static class Check
+    {
+        public static T NotNull<T>(T value, string parameterName)
+        {
+            if (value == null)
+            {
+                throw new ArgumentNullException(parameterName);
+            }
+
+            return value;
+        }
+    }
+}

+ 32 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Core/CollectionExtensions.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Core
+{
+    /// <summary>
+    /// 自定义扩展方法
+    /// </summary>
+    public static class CollectionExtensions
+    {
+        /// <summary>
+        /// 从集合移除给定条件的元素
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="source"></param>
+        /// <param name="predicate"></param>
+        /// <returns></returns>
+        public static IList<T> RemoveAll<T>(this ICollection<T> source, Func<T, bool> predicate)
+        {
+            List<T> list = source.Where(predicate).ToList();
+            foreach (T item in list)
+            {
+                source.Remove(item);
+            }
+
+            return list;
+        }
+    }
+}

+ 13 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Core/ECL142.BasicAuth.Core.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
+  </ItemGroup>
+
+</Project>

+ 28 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Core/Exceptions/BusinessException.cs

@@ -0,0 +1,28 @@
+using Microsoft.Extensions.Logging;
+
+namespace ECL142.BasicAuth.Core.Exceptions
+{
+    [Serializable]
+    public class BusinessException : Exception, IBusinessException
+    {
+        public string? Details { get; set; }
+
+        public LogLevel LogLevel { get; set; } = LogLevel.Warning;
+
+        public BusinessException()
+        {
+        }
+
+        public BusinessException(string? message = null)
+           : base(message)
+        {
+        }
+
+        public BusinessException(string? message = null, string? details = null, Exception? innerException = null, LogLevel logLevel = LogLevel.Warning)
+            : base(message, innerException)
+        {
+            Details = details;
+            LogLevel = logLevel;
+        }
+    }
+}

+ 9 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Core/Exceptions/IBusinessException.cs

@@ -0,0 +1,9 @@
+namespace ECL142.BasicAuth.Core.Exceptions
+{
+    /// <summary>
+    /// 自定义业务异常接口
+    /// </summary>
+    public interface IBusinessException
+    {
+    }
+}

+ 9 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/ECL142.BasicAuth.Domain.Shared.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>

+ 53 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/PermissionApiMethod.cs

@@ -0,0 +1,53 @@
+namespace ECL142.BasicAuth.Domain.Shared.Entities.Identity
+{
+    /// <summary>
+    /// 权限API方法
+    /// </summary>
+    public enum PermissionApiMethod
+    {
+        /// <summary>
+        /// GET
+        /// </summary>
+        GET,
+
+        /// <summary>
+        /// POST
+        /// </summary>
+        POST,
+
+        /// <summary>
+        /// DELETE
+        /// </summary>
+        DELETE,
+
+        /// <summary>
+        /// PUT
+        /// </summary>
+        PUT,
+
+        /// <summary>
+        /// PATH
+        /// </summary>
+        PATH,
+
+        /// <summary>
+        /// HEAD
+        /// </summary>
+        HEAD,
+
+        /// <summary>
+        /// OPTIONS
+        /// </summary>
+        OPTIONS,
+
+        /// <summary>
+        /// TRACE
+        /// </summary>
+        TRACE,
+
+        /// <summary>
+        /// CONNECT
+        /// </summary>
+        CONNECT
+    }
+}

+ 17 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/PermissionStatus.cs

@@ -0,0 +1,17 @@
+namespace ECL142.BasicAuth.Domain.Shared.Entities
+{
+    /// <summary>
+    /// 权限状态
+    /// </summary>
+    public enum PermissionStatus
+    {
+        /// 已禁用
+        /// </summary>
+        Forbidden,
+
+        /// <summary>
+        /// 正常
+        /// </summary>
+        Normal
+    }
+}

+ 23 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/PermissionType.cs

@@ -0,0 +1,23 @@
+namespace ECL142.BasicAuth.Domain.Shared.Entities
+{
+    /// <summary>
+    /// 权限类型
+    /// </summary>
+    public enum PermissionType
+    {
+        /// <summary>
+        /// 菜单
+        /// </summary>
+        Menu,
+
+        /// <summary>
+        /// 按钮/功能
+        /// </summary>
+        Element,
+
+        /// <summary>
+        /// API接口
+        /// </summary>
+        API
+    }
+}

+ 17 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/RoleStatus.cs

@@ -0,0 +1,17 @@
+namespace ECL142.BasicAuth.Domain.Shared.Entities
+{
+    /// <summary>
+    /// 角色状态
+    /// </summary>
+    public enum RoleStatus
+    {
+        /// 已禁用
+        /// </summary>
+        Forbidden,
+
+        /// <summary>
+        /// 正常
+        /// </summary>
+        Normal
+    }
+}

+ 17 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain.Shared/Entities/Identity/UserStatus.cs

@@ -0,0 +1,17 @@
+namespace ECL142.BasicAuth.Domain.Shared.Entities
+{
+    /// <summary>
+    /// 用户状态
+    /// </summary>
+    public enum UserStatus
+    {
+        /// 已禁用
+        /// </summary>
+        Forbidden,
+
+        /// <summary>
+        /// 正常
+        /// </summary>
+        Normal
+    }
+}

+ 53 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/DependencyInjection/ServiceCollectionExtensions.cs

@@ -0,0 +1,53 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Manager.Identity;
+
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.DependencyInjection
+{
+    public static class ServiceCollectionExtensions
+    {
+        /// <summary>
+        /// 领域注入
+        /// </summary>
+        /// <param name="services"></param>
+        public static void AddDomain(this IServiceCollection services)
+        {
+            //注入UserManager
+            services.TryAddScoped(typeof(UserManager));
+#pragma warning disable CS8603 // 可能返回 null 引用。
+            services.TryAddScoped(typeof(UserManager<EleUser>), provider => provider.GetService(typeof(UserManager)));
+#pragma warning restore CS8603 // 可能返回 null 引用。
+
+            //注入UserStore
+            services.TryAddScoped(typeof(UserStore));
+#pragma warning disable CS8603 // 可能返回 null 引用。
+            services.TryAddScoped(typeof(IUserStore<EleUser>), provider => provider.GetService(typeof(UserStore)));
+#pragma warning restore CS8603 // 可能返回 null 引用。
+
+            //注入RoleManager
+            services.TryAddScoped<RoleManager>();
+#pragma warning disable CS8603 // 可能返回 null 引用。
+            services.TryAddScoped(typeof(RoleManager<EleRole>), provider => provider.GetService(typeof(RoleManager)));
+#pragma warning restore CS8603 // 可能返回 null 引用。
+
+            //注入RoleStore
+            services.TryAddScoped<RoleStore>();
+#pragma warning disable CS8603 // 可能返回 null 引用。
+            services.TryAddScoped(typeof(IRoleStore<EleRole>), provider => provider.GetService(typeof(RoleStore)));
+#pragma warning restore CS8603 // 可能返回 null 引用。
+
+            //配置Identity的用户类型和角色
+            services.AddIdentityCore<EleUser>().AddRoles<EleRole>().AddUserStore<UserStore>()
+                .AddRoleStore<RoleStore>();
+        }
+    }
+}

+ 19 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/ECL142.BasicAuth.Domain.csproj

@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>disable</Nullable>
+    <GenerateDocumentationFile>True</GenerateDocumentationFile>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.4" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\ECL142.BasicAuth.Core\ECL142.BasicAuth.Core.csproj" />
+    <ProjectReference Include="..\ECL142.BasicAuth.Domain.Shared\ECL142.BasicAuth.Domain.Shared.csproj" />
+  </ItemGroup>
+
+</Project>

+ 23 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/AggregateRoot.cs

@@ -0,0 +1,23 @@
+namespace ECL142.BasicAuth.Domain.Entities.Commons
+{
+    /// <summary>
+    /// 聚合根
+    /// </summary>
+    /// <typeparam name="TKey">主键</typeparam>
+    public class AggregateRoot<TKey> : Entity<TKey>
+    {
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        protected AggregateRoot()
+        { }
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="id"></param>
+        protected AggregateRoot(TKey id) : base(id)
+        {
+        }
+    }
+}

+ 29 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/AuditedAggregateRoot.cs

@@ -0,0 +1,29 @@
+namespace ECL142.BasicAuth.Domain.Entities.Commons
+{
+    /// <summary>
+    /// 包含审计信息的聚合根
+    /// </summary>
+    /// <typeparam name="TKey">主键</typeparam>
+    public class AuditedAggregateRoot<TKey> : CreationAuditedAggregateRoot<TKey>
+    {
+        /// <summary>
+        /// 修改时间
+        /// </summary>
+        public DateTime? LastModificationTime { get; set; }
+
+        /// <summary>
+        /// 最后修改者
+        /// </summary>
+
+        public TKey LastModifierId { get; set; }
+
+        protected AuditedAggregateRoot()
+        {
+        }
+
+        protected AuditedAggregateRoot(TKey id)
+            : base(id)
+        {
+        }
+    }
+}

+ 23 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/CreationAuditedAggregateRoot.cs

@@ -0,0 +1,23 @@
+namespace ECL142.BasicAuth.Domain.Entities.Commons
+{
+    /// <summary>
+    /// 包含创建审计信息的聚合根
+    /// </summary>
+    /// <typeparam name="TKey">主键</typeparam>
+    public class CreationAuditedAggregateRoot<TKey> : AggregateRoot<TKey>
+    {
+        public DateTime CreationTime { get; protected set; }
+
+        public Guid? CreatorId { get; set; }
+
+        protected CreationAuditedAggregateRoot()
+        {
+        }
+
+        protected CreationAuditedAggregateRoot(TKey id)
+            : base(id)
+        {
+            CreationTime = DateTime.Now;
+        }
+    }
+}

+ 25 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/CreationAuditedEntity.cs

@@ -0,0 +1,25 @@
+namespace ECL142.BasicAuth.Domain.Entities.Commons
+{
+    /// <summary>
+    /// 包含创建审计信息的实体
+    /// </summary>
+    /// <typeparam name="TKey"></typeparam>
+    public class CreationAuditedEntity<TKey> : Entity
+    {
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public DateTime CreationTime { get; protected set; }
+
+        /// <summary>
+        /// 创建者
+        /// </summary>
+
+        public TKey CreatorId { get; set; }
+
+        protected CreationAuditedEntity()
+        {
+            CreationTime = DateTime.Now;
+        }
+    }
+}

+ 39 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Commons/Entity.cs

@@ -0,0 +1,39 @@
+namespace ECL142.BasicAuth.Domain.Entities.Commons
+{
+    /// <summary>
+    /// 实体
+    /// </summary>
+    public class Entity
+    {
+    }
+
+    /// <summary>
+    /// 带主键的实体
+    /// </summary>
+    /// <typeparam name="TKey">主键</typeparam>
+    public class Entity<TKey> : Entity
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        public TKey Id { get; protected set; }
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
+        protected Entity()
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        {
+        }
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        protected Entity(TKey id)
+        {
+            Id = id;
+        }
+    }
+}

+ 134 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/ElePermission.cs

@@ -0,0 +1,134 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+using ECL142.BasicAuth.Domain.Shared.Entities;
+using ECL142.BasicAuth.Domain.Shared.Entities.Identity;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    public class ElePermission : AuditedAggregateRoot<Guid>
+    {
+        /// <summary>
+        /// 权限名称
+        /// </summary>
+        public string Name { get; protected set; }
+
+        /// <summary>
+        /// 权限编码
+        /// </summary>
+        public string Code { get; protected set; }
+
+        /// <summary>
+        /// Url地址
+        /// </summary>
+        public string Url { get; set; }
+
+        /// <summary>
+        /// Vue页面组件
+        /// </summary>
+        public string Component { get; set; }
+
+        /// <summary>
+        /// 图标
+        /// </summary>
+        public string Icon { get; set; }
+
+        /// <summary>
+        /// 菜单类型:菜单权限、元素权限、Api权限、数据权限
+        /// </summary>
+        public PermissionType PermissionType { get; set; }
+
+        /// <summary>
+        /// API方法
+        /// </summary>
+        public string ApiMethod { get; protected set; }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 父菜单Id
+        /// </summary>
+        public Guid? ParentId { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public PermissionStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+        /// <summary>
+        /// 无参构造函数
+        /// </summary>
+        protected ElePermission()
+        {
+        }
+
+        /// <summary>
+        /// 有参构造函数
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="parentId"></param>
+        /// <param name="name"></param>
+        /// <param name="code"></param>
+        /// <param name="permissionType"></param>
+        /// <param name="apiMethod"></param>
+        /// <param name="permissionStatus"></param>
+        /// <param name="icon"></param>
+        /// <param name="url"></param>
+        /// <param name="remark"></param>
+        public ElePermission(Guid id, Guid? parentId, string name, string code, PermissionType permissionType, PermissionApiMethod apiMethod,
+            PermissionStatus permissionStatus, string icon = null, string url = null, string remark = null) : base(id)
+        {
+            Check.NotNull(name, nameof(name));
+            Check.NotNull(code, nameof(code));
+
+            ParentId = parentId;
+            Name = name;
+            Code = code;
+            PermissionType = permissionType;
+            ApiMethod = apiMethod.ToString();
+            Status = permissionStatus;
+            Sort = 0;
+            Icon = icon;
+            Url = url;
+            Remark = remark;
+        }
+
+        /// <summary>
+        /// 设置API方法
+        /// </summary>
+        /// <param name="apiMethod"></param>
+        public void SetApiMethod(PermissionApiMethod apiMethod)
+        {
+            ApiMethod = apiMethod.ToString();
+        }
+
+        /// <summary>
+        /// 设置名称
+        /// </summary>
+        /// <param name="name"></param>
+        public void SetName(string name)
+        {
+            Check.NotNull(name, nameof(name));
+
+            Name = name;
+        }
+
+        /// <summary>
+        /// 设置编码
+        /// </summary>
+        /// <param name="code"></param>
+        public void SetCode(string code)
+        {
+            Check.NotNull(code, nameof(code));
+
+            Code = code;
+        }
+    }
+}

+ 104 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleRole.cs

@@ -0,0 +1,104 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using System.Collections.ObjectModel;
+using System.Security.Claims;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    public class EleRole : AuditedAggregateRoot<Guid>
+    {
+        /// <summary>
+        /// 角色名称
+        /// </summary>
+        public string Name { get; protected set; }
+
+        /// <summary>
+        /// 标准化角色名称
+        /// </summary>
+        public string NormalizedName { get; internal set; }
+
+        /// <summary>
+        /// 一个随机值,只要角色被持久化到存储中,该值就应该更改
+        /// </summary>
+        public string ConcurrencyStamp { get; protected set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public RoleStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+        /// <summary>
+        /// 声明列表
+        /// </summary>
+        public List<EleRoleClaim> Claims { get; protected set; }
+
+        /// <summary>
+        /// 权限列表
+        /// </summary>
+        public List<EleRolePermission> Permissions { get; protected set; }
+
+        protected EleRole()
+        {
+        }
+
+        public EleRole(Guid id, string name) : base(id)
+        {
+            Check.NotNull(name, nameof(name));
+
+            Name = name;
+            NormalizedName = name.ToUpperInvariant();
+            ConcurrencyStamp = Guid.NewGuid().ToString("N");
+            Status = RoleStatus.Normal;
+
+            Claims = new List<EleRoleClaim>();
+            Permissions = new List<EleRolePermission>();
+        }
+
+        public void SetName(string name)
+        {
+            Check.NotNull(name, nameof(name));
+
+            Name = name;
+            NormalizedName = name.ToUpperInvariant();
+        }
+
+        public void AddClaim(Claim claim)
+        {
+            Check.NotNull(claim, nameof(claim));
+
+            if (!Claims.Any(x => x.RoleId == Id && x.ClaimType == claim.Type))
+            {
+                Claims.Add(new EleRoleClaim(Guid.NewGuid(), Id, claim));
+            }
+        }
+
+        public void RemoveClaim(Claim claim)
+        {
+            Check.NotNull(claim, nameof(claim));
+
+            Claims.RemoveAll(x => x.RoleId == Id && x.ClaimType == claim.Type);
+        }
+
+        public void AddPermission(Guid permissionId)
+        {
+            Permissions.Add(new EleRolePermission(Id, permissionId));
+        }
+
+        public void RemovePermission(Guid permissionId)
+        {
+            Permissions.RemoveAll(x => x.RoleId == Id && x.PermissionId == permissionId);
+        }
+
+        public void RemoveAllPermission()
+        {
+            Permissions = new List<EleRolePermission>();
+        }
+    }
+}

+ 50 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleRoleClaim.cs

@@ -0,0 +1,50 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+using System.Security.Claims;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    public class EleRoleClaim : Entity<Guid>
+    {
+        /// <summary>
+        /// 角色Id
+        /// </summary>
+        public Guid RoleId { get; protected set; }
+
+        /// <summary>
+        /// 声明类型
+        /// </summary>
+        public string ClaimType { get; protected set; }
+
+        /// <summary>
+        /// 类型值
+        /// </summary>
+        public string ClaimValue { get; protected set; }
+
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
+        protected EleRoleClaim()
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        { }
+
+        public EleRoleClaim(Guid id, Guid roleId, Claim claim) : base(id)
+        {
+            Check.NotNull(claim, nameof(claim));
+
+            RoleId = roleId;
+            ClaimType = claim.Type;
+            ClaimValue = claim.Value;
+        }
+
+        public void SetClaimValue(string claimValue)
+        {
+            if (claimValue == null)
+            {
+                throw new ArgumentNullException(nameof(claimValue));
+            }
+
+            ClaimValue = claimValue;
+        }
+    }
+}

+ 29 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleRolePermission.cs

@@ -0,0 +1,29 @@
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    /// <summary>
+    /// 角色权限关联
+    /// </summary>
+    public class EleRolePermission : CreationAuditedEntity<Guid>
+    {
+        /// <summary>
+        /// 角色Id
+        /// </summary>
+        public Guid RoleId { get; protected set; }
+
+        /// <summary>
+        /// 菜单Id
+        /// </summary>
+        public Guid PermissionId { get; protected set; }
+
+        protected EleRolePermission()
+        { }
+
+        public EleRolePermission(Guid roleId, Guid permissionId)
+        {
+            RoleId = roleId;
+            PermissionId = permissionId;
+        }
+    }
+}

+ 332 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUser.cs

@@ -0,0 +1,332 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using Microsoft.AspNetCore.Identity;
+
+using System.Collections.ObjectModel;
+using System.Security.Claims;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    /// <summary>
+    /// 用户
+    /// </summary>
+    public class EleUser : AuditedAggregateRoot<Guid>
+    {
+        /// <summary>
+        /// 用户名
+        /// </summary>
+        public string UserName { get; protected set; }
+
+        /// <summary>
+        /// 标准化用户名
+        /// </summary>
+        public string NormalizedUserName { get; protected internal set; }
+
+        /// <summary>
+        /// Email
+        /// </summary>
+        public string Email { get; protected set; }
+
+        /// <summary>
+        /// 标准化Email
+        /// </summary>
+        public string NormalizedEmail { get; protected set; }
+
+        /// <summary>
+        /// 邮箱是否确认
+        /// </summary>
+        public bool EmailConfirmed { get; protected set; }
+
+        /// <summary>
+        /// 密码哈希
+        /// </summary>
+        public string PasswordHash { get; protected set; }
+
+        /// <summary>
+        /// 一个随机值,每当用户凭据更改时(密码更改、登录删除),该值都必须更改
+        /// </summary>
+        public string SecurityStamp { get; protected set; }
+
+        /// <summary>
+        /// 一个随机值,每当用户被持久化到存储时,该值必须更改
+        /// </summary>
+        public string ConcurrencyStamp { get; protected set; }
+
+        /// <summary>
+        /// 获取或设置用户的电话号码。
+        /// </summary>
+        public string PhoneNumber { get; set; }
+
+        /// <summary>
+        /// 获取或设置一个标志,该标志指示用户是否已确认其电话地址。
+        /// </summary>
+        public bool PhoneNumberConfirmed { get; protected set; }
+
+        /// <summary>
+        /// 获取或设置一个标志,该标志指示是否为此用户启用了双因素身份验证。
+        /// </summary>
+        public bool TwoFactorEnabled { get; protected set; }
+
+        /// <summary>
+        /// 获取或设置任何用户锁定结束的日期和时间(以UTC为单位)。
+        /// </summary>
+        public DateTimeOffset? LockoutEnd { get; protected set; }
+
+        /// <summary>
+        /// 获取或设置一个标志,该标志指示用户是否可以被锁定。
+        /// </summary>
+        public bool LockoutEnabled { get; protected set; }
+
+        /// <summary>
+        /// 获取或设置当前用户登录尝试失败的次数。
+        /// </summary>
+        public int AccessFailedCount { get; protected set; }
+
+        /// <summary>
+        /// 全名:姓名
+        /// </summary>
+        public string FullName { get; set; }
+
+        /// <summary>
+        /// 状态,0:禁用,1:正常
+        /// </summary>
+        public UserStatus Status { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+        /// <summary>
+        /// 角色列表
+        /// </summary>
+        public List<EleUserRole> Roles { get; protected set; }
+
+        /// <summary>
+        /// 用户声明列表
+        /// </summary>
+        public List<EleUserClaim> Claims { get; protected set; }
+
+        /// <summary>
+        /// 用户登录列表
+        /// </summary>
+        public ICollection<EleUserLogin> Logins { get; protected set; }
+
+        /// <summary>
+        /// token列表
+        /// </summary>
+        public List<EleUserToken> Tokens { get; protected set; }
+
+        /// <summary>
+        /// 无参构造函数
+        /// </summary>
+        protected EleUser()
+        {
+        }
+
+        /// <summary>
+        /// 构造函数二
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="userName">用户名</param>
+        /// <param name="email">邮箱</param>
+        /// <param name="fullName">全名</param>
+        /// <param name="remark">备注</param>
+
+        public EleUser(Guid id, string userName, string email = null, string fullName = null, string remark = null) : base(id)
+        {
+            Check.NotNull(userName, nameof(userName));
+
+            UserName = userName;
+            NormalizedUserName = userName.ToUpperInvariant();
+            Email = email ?? string.Empty;
+            FullName = fullName;
+            NormalizedEmail = email?.ToUpperInvariant() ?? string.Empty;
+            EmailConfirmed = true;
+            ConcurrencyStamp = Guid.NewGuid().ToString("N");
+            SecurityStamp = Guid.NewGuid().ToString();
+            Status = UserStatus.Normal;
+            Remark = remark;
+
+            Roles = new List<EleUserRole>();
+            Claims = new List<EleUserClaim>();
+            Logins = new List<EleUserLogin>();
+            Tokens = new List<EleUserToken>();
+        }
+
+        /// <summary>
+        /// 添加角色
+        /// </summary>
+        /// <param name="roleId"></param>
+        public void AddRole(Guid roleId)
+        {
+            Check.NotNull(roleId, nameof(roleId));
+
+            if (IsInRole(roleId))
+            {
+                return;
+            }
+
+            Roles.Add(new EleUserRole(Id, roleId));
+        }
+
+        public void RemoveRole(Guid roleId)
+        {
+            Check.NotNull(roleId, nameof(roleId));
+
+            if (!IsInRole(roleId))
+            {
+                return;
+            }
+
+            Roles.RemoveAll(r => r.RoleId == roleId);
+        }
+
+        /// <summary>
+        /// 移除角色
+        /// </summary>
+        public void RemoveAllRoles()
+        {
+            Roles = new List<EleUserRole>();
+        }
+
+        /// <summary>
+        /// 是否拥有某个角色
+        /// </summary>
+        /// <param name="roleId"></param>
+        /// <returns></returns>
+        public bool IsInRole(Guid roleId)
+        {
+            Check.NotNull(roleId, nameof(roleId));
+
+            return Roles.Any(r => r.RoleId == roleId);
+        }
+
+        /// <summary>
+        /// 设置用户名
+        /// </summary>
+        /// <param name="userName"></param>
+        public void SetUserName(string userName)
+        {
+            Check.NotNull(userName, nameof(userName));
+
+            UserName = userName;
+            NormalizedUserName = userName.ToUpperInvariant();
+        }
+
+        /// <summary>
+        /// 设置邮箱
+        /// </summary>
+        /// <param name="email"></param>
+        public void SetEmail(string email)
+        {
+            Email = email;
+            NormalizedEmail = email?.ToUpperInvariant();
+        }
+
+        /// <summary>
+        /// 设置密码
+        /// </summary>
+        /// <param name="passwordHash"></param>
+        public void SetPasswordHash(string passwordHash)
+        {
+            Check.NotNull(passwordHash, nameof(passwordHash));
+
+            PasswordHash = passwordHash;
+        }
+
+        /// <summary>
+        /// 添加声明
+        /// </summary>
+        /// <param name="claim"></param>
+
+        public void AddClaim(Claim claim)
+        {
+            Check.NotNull(claim, nameof(claim));
+
+            if (!Claims.Any(x => x.UserId == Id && x.ClaimType == claim.Type))
+            {
+                Claims.Add(new EleUserClaim(Guid.NewGuid(), Id, claim));
+            }
+        }
+
+        /// <summary>
+        /// 移除声明
+        /// </summary>
+        /// <param name="claim"></param>
+        public void RemoveClaim(Claim claim)
+        {
+            Check.NotNull(claim, nameof(claim));
+
+            Claims.RemoveAll(x => x.UserId == Id && x.ClaimType == claim.Type);
+        }
+
+        /// <summary>
+        /// 添加登录信息
+        /// </summary>
+        /// <param name="login"></param>
+        public void AddLogin(UserLoginInfo login)
+        {
+            Check.NotNull(login, nameof(login));
+
+            Logins.Add(new EleUserLogin(login, Id));
+        }
+
+        /// <summary>
+        /// 一处登录信息
+        /// </summary>
+        /// <param name="loginProvider"></param>
+        /// <param name="providerKey"></param>
+
+        public void RemoveLogin(string loginProvider, string providerKey)
+        {
+            Check.NotNull(loginProvider, nameof(loginProvider));
+            Check.NotNull(providerKey, nameof(providerKey));
+
+            Logins.RemoveAll(userLogin =>
+                userLogin.LoginProvider == loginProvider && userLogin.ProviderKey == providerKey);
+        }
+
+        /// <summary>
+        /// 检索令牌
+        /// </summary>
+        /// <param name="loginProvider"></param>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public EleUserToken FindToken(string loginProvider, string name)
+        {
+            return Tokens.FirstOrDefault(t => t.LoginProvider == loginProvider && t.Name == name);
+        }
+
+        /// <summary>
+        /// 设置令牌
+        /// </summary>
+        /// <param name="loginProvider"></param>
+        /// <param name="name"></param>
+        /// <param name="value"></param>
+        public void SetToken(string loginProvider, string name, string value)
+        {
+            var token = FindToken(loginProvider, name);
+            if (token == null)
+            {
+                Tokens.Add(new EleUserToken(Id, loginProvider, name, value));
+            }
+            else
+            {
+                token.SetValue(value);
+            }
+        }
+
+        /// <summary>
+        /// 移除令牌
+        /// </summary>
+        /// <param name="loginProvider"></param>
+        /// <param name="name"></param>
+        public void RemoveToken(string loginProvider, string name)
+        {
+            Tokens.RemoveAll(t => t.LoginProvider == loginProvider && t.Name == name);
+        }
+    }
+}

+ 48 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserClaim.cs

@@ -0,0 +1,48 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+using System.Security.Claims;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    public class EleUserClaim : Entity<Guid>
+    {
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        public Guid UserId { get; protected set; }
+
+        /// <summary>
+        /// 声明类型
+        /// </summary>
+        public string ClaimType { get; protected set; }
+
+        /// <summary>
+        /// 声明类型的值
+        /// </summary>
+        public string ClaimValue { get; protected set; }
+
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
+        protected EleUserClaim()
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        {
+        }
+
+        public EleUserClaim(Guid id, Guid userId, Claim claim) : base(id)
+        {
+            Check.NotNull(claim, nameof(claim));
+
+            UserId = userId;
+            ClaimType = claim.Type;
+            ClaimValue = claim.Value;
+        }
+
+        public void SetClaimValue(string claimValue)
+        {
+            Check.NotNull(claimValue, nameof(claimValue));
+
+            ClaimValue = claimValue;
+        }
+    }
+}

+ 62 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserLogin.cs

@@ -0,0 +1,62 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+using Microsoft.AspNetCore.Identity;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    public class EleUserLogin : Entity
+    {
+        /// <summary>
+        /// 登录提供程序
+        /// </summary>
+        public string LoginProvider { get; protected set; }
+
+        /// <summary>
+        /// ProviderKey
+        /// </summary>
+        public string ProviderKey { get; protected set; }
+
+        /// <summary>
+        /// 提供程序显示名称
+        /// </summary>
+        public string ProviderDisplayName { get; protected set; }
+
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        public Guid UserId { get; protected set; }
+
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
+        protected EleUserLogin()
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        {
+        }
+
+        public EleUserLogin(string loginProvider, string providerKey, string providerDisplayName, Guid userId)
+        {
+            Check.NotNull(loginProvider, nameof(loginProvider));
+            Check.NotNull(providerKey, nameof(providerKey));
+            Check.NotNull(providerDisplayName, nameof(providerDisplayName));
+
+            LoginProvider = loginProvider;
+            ProviderKey = providerKey;
+            ProviderDisplayName = providerDisplayName;
+            UserId = userId;
+        }
+
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
+        public EleUserLogin(UserLoginInfo login, Guid userId)
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        {
+            Check.NotNull(login, nameof(login));
+
+            LoginProvider = login.LoginProvider;
+            ProviderKey = login.ProviderKey;
+            ProviderDisplayName = login.ProviderDisplayName;
+            UserId = userId;
+        }
+    }
+}

+ 37 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserRole.cs

@@ -0,0 +1,37 @@
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    /// <summary>
+    /// 用户角色关联
+    /// </summary>
+    public class EleUserRole : CreationAuditedEntity<Guid>
+    {
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        public Guid UserId { get; protected set; }
+
+        /// <summary>
+        /// 角色Id
+        /// </summary>
+        public Guid RoleId { get; protected set; }
+
+        /// <summary>
+        /// 无参构造函数
+        /// </summary>
+        protected EleUserRole()
+        { }
+
+        /// <summary>
+        /// 有参构造函数
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <param name="roleId"></param>
+        public EleUserRole(Guid userId, Guid roleId)
+        {
+            UserId = userId;
+            RoleId = roleId;
+        }
+    }
+}

+ 57 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Entities/Identity/EleUserToken.cs

@@ -0,0 +1,57 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+namespace ECL142.BasicAuth.Domain.Entities.Identity
+{
+    /// <summary>
+    /// 用户凭证
+    /// </summary>
+    public class EleUserToken : Entity
+    {
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        public Guid UserId { get; protected set; }
+
+        /// <summary>
+        /// 登录提供程序
+        /// </summary>
+        public string LoginProvider { get; protected set; }
+
+        /// <summary>
+        /// token名称
+        /// </summary>
+        public string Name { get; protected set; }
+
+        /// <summary>
+        /// token值
+        /// </summary>
+        public string Value { get; protected set; }
+
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
+        protected EleUserToken()
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        {
+        }
+
+        public EleUserToken(Guid userId, string loginProvider, string name, string value)
+        {
+            Check.NotNull(loginProvider, nameof(loginProvider));
+            Check.NotNull(name, nameof(name));
+            Check.NotNull(value, nameof(value));
+
+            UserId = userId;
+            LoginProvider = loginProvider;
+            Name = name;
+            Value = value;
+        }
+
+        public void SetValue(string value)
+        {
+            Check.NotNull(value, nameof(value));
+
+            Value = value;
+        }
+    }
+}

+ 12 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/IDomainService.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Manager
+{
+    public interface IDomainService
+    {
+    }
+}

+ 25 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/RoleManager.cs

@@ -0,0 +1,25 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Logging;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Manager.Identity
+{
+    public class RoleManager : RoleManager<EleRole>, IDomainService
+    {
+        private RoleStore _roleStore;
+
+        public RoleManager(RoleStore store, IEnumerable<IRoleValidator<EleRole>> roleValidators,
+            ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, ILogger<RoleManager> logger)
+            : base(store, roleValidators, keyNormalizer, errors, logger)
+        {
+            _roleStore = store;
+        }
+    }
+}

+ 211 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/RoleStore.cs

@@ -0,0 +1,211 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Repositories.Identity;
+
+using Microsoft.AspNetCore.Identity;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Manager.Identity
+{
+    public class RoleStore : IRoleStore<EleRole>
+    {
+        private IRoleRepository _roleRepository;
+
+        public RoleStore(IRoleRepository roleRepository)
+        {
+            _roleRepository = roleRepository;
+        }
+
+        public bool AutoSaveChanges { get; set; } = true;
+
+        /// <summary>
+        /// 创建角色
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IdentityResult> CreateAsync(EleRole role, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            await _roleRepository.InsertAsync(role, AutoSaveChanges, cancellationToken);
+
+            return IdentityResult.Success;
+        }
+
+        /// <summary>
+        /// 删除角色
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IdentityResult> DeleteAsync(EleRole role, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken);
+
+            return IdentityResult.Success;
+        }
+
+        public void Dispose()
+        {
+        }
+
+        /// <summary>
+        /// 根据Id获取角色
+        /// </summary>
+        /// <param name="roleId"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+
+        public async Task<EleRole> FindByIdAsync(string roleId, CancellationToken cancellationToken)
+#pragma warning restore CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(roleId, nameof(roleId));
+
+            return await _roleRepository.FindAsync(Guid.Parse(roleId), AutoSaveChanges, cancellationToken);
+        }
+
+        /// <summary>
+        /// 根据角色名称获取角色
+        /// </summary>
+        /// <param name="normalizedRoleName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+
+        public async Task<EleRole> FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken)
+#pragma warning restore CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(normalizedRoleName, nameof(normalizedRoleName));
+
+            return await _roleRepository.FindByNameAsync(normalizedRoleName, AutoSaveChanges, cancellationToken);
+        }
+
+        /// <summary>
+        /// 获取格式化的角色名称
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+
+        public Task<string> GetNormalizedRoleNameAsync(EleRole role, CancellationToken cancellationToken)
+#pragma warning restore CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            return Task.FromResult(role.NormalizedName);
+        }
+
+        /// <summary>
+        /// 获取角色Id
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task<string> GetRoleIdAsync(EleRole role, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            return Task.FromResult(role.Id.ToString());
+        }
+
+        /// <summary>
+        /// 获取角色名称
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+
+        public Task<string> GetRoleNameAsync(EleRole role, CancellationToken cancellationToken)
+#pragma warning restore CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            return Task.FromResult(role.Name);
+        }
+
+        /// <summary>
+        /// 设置格式化的角色名称
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="normalizedName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8767 // 参数类型中引用类型的为 Null 性与隐式实现的成员不匹配(可能是由于为 Null 性特性)。
+
+        public Task SetNormalizedRoleNameAsync(EleRole role, string normalizedName, CancellationToken cancellationToken)
+#pragma warning restore CS8767 // 参数类型中引用类型的为 Null 性与隐式实现的成员不匹配(可能是由于为 Null 性特性)。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            role.NormalizedName = normalizedName;
+
+            return Task.CompletedTask;
+        }
+
+        /// <summary>
+        /// 设置角色名称
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="roleName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8767 // 参数类型中引用类型的为 Null 性与隐式实现的成员不匹配(可能是由于为 Null 性特性)。
+
+        public Task SetRoleNameAsync(EleRole role, string roleName, CancellationToken cancellationToken)
+#pragma warning restore CS8767 // 参数类型中引用类型的为 Null 性与隐式实现的成员不匹配(可能是由于为 Null 性特性)。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            role.SetName(roleName);
+
+            return Task.CompletedTask;
+        }
+
+        /// <summary>
+        /// 更新角色
+        /// </summary>
+        /// <param name="role"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IdentityResult> UpdateAsync(EleRole role, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(role, nameof(role));
+
+            role.LastModificationTime = DateTime.Now;
+            await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken);
+
+            return IdentityResult.Success;
+        }
+    }
+}

+ 43 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/UserManager.cs

@@ -0,0 +1,43 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace ECL142.BasicAuth.Domain.Manager.Identity
+{
+    /// <summary>
+    /// 用户管理器
+    /// </summary>
+    public class UserManager : UserManager<EleUser>, IDomainService
+    {
+        private UserStore _userStore;
+
+        /// <summary>
+        /// 用户管理器
+        /// </summary>
+        /// <param name="store"></param>
+        /// <param name="optionsAccessor"></param>
+        /// <param name="passwordHasher"></param>
+        /// <param name="userValidators"></param>
+        /// <param name="passwordValidators"></param>
+        /// <param name="keyNormalizer"></param>
+        /// <param name="errors"></param>
+        /// <param name="services"></param>
+        /// <param name="logger"></param>
+        public UserManager(UserStore store,
+            IOptions<IdentityOptions> optionsAccessor,
+            IPasswordHasher<EleUser> passwordHasher,
+            IEnumerable<IUserValidator<EleUser>> userValidators,
+            IEnumerable<IPasswordValidator<EleUser>> passwordValidators,
+            ILookupNormalizer keyNormalizer,
+            IdentityErrorDescriber errors,
+            IServiceProvider services,
+            ILogger<UserManager<EleUser>> logger
+            ) :
+            base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
+        {
+            _userStore = store;
+        }
+    }
+}

+ 346 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Manager/Identity/UserStore.cs

@@ -0,0 +1,346 @@
+using ECL142.BasicAuth.Core;
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Repositories.Identity;
+
+using Microsoft.AspNetCore.Identity;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Manager.Identity
+{
+    public class UserStore : IUserStore<EleUser>, IUserPasswordStore<EleUser>, IUserRoleStore<EleUser>
+    {
+        private IUserRepository _userRepository;
+        private IRoleRepository _roleRepository;
+
+        public bool AutoSaveChanges { get; set; } = true;
+
+        public UserStore(IUserRepository userRepository, IRoleRepository roleRepository)
+        {
+            _userRepository = userRepository;
+            _roleRepository = roleRepository;
+        }
+
+        /// <summary>
+        /// 新增用户
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IdentityResult> CreateAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            await _userRepository.InsertAsync(user, AutoSaveChanges, cancellationToken);
+
+            return IdentityResult.Success;
+        }
+
+        /// <summary>
+        /// 删除用户
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IdentityResult> DeleteAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            await _userRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken);
+
+            return IdentityResult.Success;
+        }
+
+        public void Dispose()
+        {
+        }
+
+        /// <summary>
+        /// 根据用户Id获取用户
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+#pragma warning disable CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+
+        public async Task<EleUser> FindByIdAsync(string userId, CancellationToken cancellationToken)
+#pragma warning restore CS8613 // 返回类型中引用类型的为 Null 性与隐式实现的成员不匹配。
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(userId, nameof(userId));
+
+            return await _userRepository.FindAsync(Guid.Parse(userId), AutoSaveChanges, cancellationToken);
+        }
+
+        /// <summary>
+        /// 根据用户名获取用户
+        /// </summary>
+        /// <param name="normalizedUserName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+
+        public async Task<EleUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(normalizedUserName, nameof(normalizedUserName));
+
+            return await _userRepository.FindByNameAsync(normalizedUserName, AutoSaveChanges, cancellationToken);
+        }
+
+        /// <summary>
+        /// 根据格式的用户名获取用户
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+
+        public Task<string> GetNormalizedUserNameAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            return Task.FromResult(user.NormalizedUserName);
+        }
+
+        /// <summary>
+        /// 获取密码哈希值
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task<string> GetPasswordHashAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            return Task.FromResult(user.PasswordHash);
+        }
+
+        /// <summary>
+        /// 获取用户Id
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task<string> GetUserIdAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            return Task.FromResult(user.Id.ToString());
+        }
+
+        /// <summary>
+        /// 获取用户名
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+
+        public Task<string> GetUserNameAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            return Task.FromResult(user.UserName);
+        }
+
+        /// <summary>
+        /// 判断用户是否有密码
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task<bool> HasPasswordAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            return Task.FromResult(string.IsNullOrEmpty(user.PasswordHash));
+        }
+
+        /// <summary>
+        /// 格式化用户名
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="normalizedName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task SetNormalizedUserNameAsync(EleUser user, string normalizedName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            user.NormalizedUserName = normalizedName;
+
+            return Task.CompletedTask;
+        }
+
+        /// <summary>
+        /// 设置用户密码
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="passwordHash"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task SetPasswordHashAsync(EleUser user, string passwordHash, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+            user.SetPasswordHash(passwordHash);
+
+            return Task.CompletedTask;
+        }
+
+        /// <summary>
+        /// 设置用户名
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="userName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public Task SetUserNameAsync(EleUser user, string userName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            user.SetUserName(userName);
+
+            return Task.CompletedTask;
+        }
+
+        /// <summary>
+        /// 更新用户
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IdentityResult> UpdateAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            user.LastModificationTime = DateTime.Now;
+            await _userRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken);
+
+            return IdentityResult.Success;
+        }
+
+        /// <summary>
+        /// 给用户分配角色
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="roleName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public async Task AddToRoleAsync(EleUser user, string roleName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+            Check.NotNull(roleName, nameof(roleName));
+
+            var role = await _roleRepository.FindByNameAsync(roleName, cancellationToken: cancellationToken);
+            if (role == null)
+            {
+                throw new Exception("角色不存在,角色名称:" + roleName);
+            }
+
+            user.AddRole(role.Id);
+        }
+
+        /// <summary>
+        /// 移除用户的角色
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="roleName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task RemoveFromRoleAsync(EleUser user, string roleName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+            Check.NotNull(roleName, nameof(roleName));
+
+            var role = await _roleRepository.FindByNameAsync(roleName, cancellationToken: cancellationToken);
+            if (role == null)
+            {
+                return;
+            }
+
+            user.RemoveRole(role.Id);
+        }
+
+        /// <summary>
+        /// 获取角色列表
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IList<string>> GetRolesAsync(EleUser user, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+
+            var roleNames = await _userRepository.GetRoleNamesAsync(user.Id, cancellationToken);
+
+            return roleNames;
+        }
+
+        /// <summary>
+        /// 判断用户是否包含某角色
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="roleName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<bool> IsInRoleAsync(EleUser user, string roleName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(user, nameof(user));
+            Check.NotNull(roleName, nameof(roleName));
+
+            var roles = await GetRolesAsync(user, cancellationToken);
+
+            return roles.Contains(roleName);
+        }
+
+        /// <summary>
+        /// 根据角色名获取用户列表
+        /// </summary>
+        /// <param name="roleName"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<IList<EleUser>> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+
+            Check.NotNull(roleName, nameof(roleName));
+
+            return await _userRepository.GetListByRoleNameAsync(roleName, cancellationToken: cancellationToken);
+        }
+    }
+}

+ 144 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/IBasicRepository.cs

@@ -0,0 +1,144 @@
+using ECL142.BasicAuth.Domain.Entities.Commons;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Repositories
+{
+    /// <summary>
+    /// 仓储基接口
+    /// </summary>
+    public interface IBasicRepository<TEntity, TKey> : IRepository where TEntity : Entity<TKey>
+    {
+        /// <summary>
+        /// 获取所有记录列表
+        /// </summary>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 获取总记录数
+        /// </summary>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<long> GetCountAsync(CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 翻页获取记录列表
+        /// </summary>
+        /// <param name="skipCount"></param>
+        /// <param name="maxResultCount"></param>
+        /// <param name="sorting"></param>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 根据筛选条件获取记录列表
+        /// </summary>
+        /// <param name="filter"></param>
+        /// <param name="skipCount"></param>
+        /// <param name="maxResultCount"></param>
+        /// <param name="sorting"></param>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> filter, int skipCount, int maxResultCount, string sorting, bool includeDetails = true, CancellationToken cancellationToken = default);
+
+        /// <summary>
+        /// 根据筛选条件获取记录总数
+        /// </summary>
+        /// <param name="filter"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<long> GetCountAsync(Expression<Func<TEntity, bool>> filter, CancellationToken cancellationToken = default);
+
+        /// <summary>
+        /// 根据主键Id获取记录
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 插入记录
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 批量插入记录
+        /// </summary>
+        /// <param name="entities"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 更新记录
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 批量更新记录
+        /// </summary>
+        /// <param name="entities"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 根据实体删除记录
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 批量删除记录
+        /// </summary>
+        /// <param name="entities"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 根据主键删除记录
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+
+        /// <summary>
+        /// 根据主键,批量删除记录
+        /// </summary>
+        /// <param name="ids"></param>
+        /// <param name="autoSave"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task DeleteManyAsync(IEnumerable<TKey> ids, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken));
+    }
+}

+ 15 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/IRepository.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Repositories
+{
+    /// <summary>
+    /// 仓储顶级接口,方便实现自动化注入
+    /// </summary>
+    public interface IRepository
+    {
+    }
+}

+ 17 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/Identity/IPermissionRepository.cs

@@ -0,0 +1,17 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Repositories.Identity
+{
+    /// <summary>
+    /// 权限仓储接口
+    /// </summary>
+    public interface IPermissionRepository : IBasicRepository<ElePermission, Guid>
+    {
+    }
+}

+ 22 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/Identity/IRoleRepository.cs

@@ -0,0 +1,22 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Repositories.Identity
+{
+    public interface IRoleRepository : IBasicRepository<EleRole, Guid>
+    {
+        /// <summary>
+        /// 根据角色名称获取角色
+        /// </summary>
+        /// <param name="roleName"></param>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<EleRole> FindByNameAsync(string roleName, bool includeDetails = true, CancellationToken cancellationToken = default);
+    }
+}

+ 39 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.Domain/Repositories/Identity/IUserRepository.cs

@@ -0,0 +1,39 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ECL142.BasicAuth.Domain.Repositories.Identity
+{
+    public interface IUserRepository : IBasicRepository<EleUser, Guid>
+    {
+        /// <summary>
+        /// 根据用户名获取用户
+        /// </summary>
+        /// <param name="userName"></param>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<EleUser> FindByNameAsync(string userName, bool includeDetails = true, CancellationToken cancellationToken = default);
+
+        /// <summary>
+        /// 根据用户Id,获取角色列表
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<List<string>> GetRoleNamesAsync(Guid id, CancellationToken cancellationToken = default);
+
+        /// <summary>
+        /// 根据用户名获取用户列表
+        /// </summary>
+        /// <param name="roleName"></param>
+        /// <param name="includeDetails"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        Task<List<EleUser>> GetListByRoleNameAsync(string roleName, bool includeDetails = true, CancellationToken cancellationToken = default);
+    }
+}

+ 25 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations.csproj

@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <Nullable>disable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+	  <!--如果迁移时出现 一下异常时,请将InvariantGlobalization 设置为false
+	  Only the invariant culture is supported in globalization-invariant mode. 
+	  See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
+	  en-us is an invalid culture identifier.-->
+	  <InvariantGlobalization>false</InvariantGlobalization>
+  </PropertyGroup>
+
+	<ItemGroup>
+		<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
+			<PrivateAssets>all</PrivateAssets>
+			<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+		</PackageReference>
+	</ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\ECL142.BasicAuth.EntityFrameworkCore\ECL142.BasicAuth.EntityFrameworkCore.csproj" />
+  </ItemGroup>
+
+</Project>

+ 6 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations.http

@@ -0,0 +1,6 @@
+@ECL142.BasicAuth.EntityFrameworkCore.DbMigrations_HostAddress = http://localhost:5216
+
+GET {{ECL142.BasicAuth.EntityFrameworkCore.DbMigrations_HostAddress}}/weatherforecast/
+Accept: application/json
+
+###

+ 809 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Migrations/20240413234821_InitDB.Designer.cs

@@ -0,0 +1,809 @@
+// <auto-generated />
+using System;
+using ECL142.BasicAuth.EntityFrameworkCore.Repository;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.DbMigrations.Migrations
+{
+    [DbContext(typeof(ApplicationDbContext))]
+    [Migration("20240413234821_InitDB")]
+    partial class InitDB
+    {
+        /// <inheritdoc />
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
+        {
+#pragma warning disable 612, 618
+            modelBuilder
+                .HasAnnotation("ProductVersion", "8.0.4")
+                .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.ElePermission", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ApiMethod")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Code")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Component")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid?>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Icon")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("LastModificationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("LastModifierId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Name")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<Guid?>("ParentId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<int>("PermissionType")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Remark")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("Sort")
+                        .HasColumnType("int");
+
+                    b.Property<int>("Status")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Url")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CreationTime");
+
+                    b.ToTable("ElePermission", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            Id = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            ApiMethod = "GET",
+                            Code = "system",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1218),
+                            Icon = "el-icon-s-tools",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "系统管理",
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            ApiMethod = "GET",
+                            Code = "system.user",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1241),
+                            Icon = "el-icon-user-solid",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "用户管理",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            ApiMethod = "GET",
+                            Code = "system.role",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1244),
+                            Icon = "peoples",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "角色管理",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            ApiMethod = "GET",
+                            Code = "system.permission",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1245),
+                            Icon = "list",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "菜单管理",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("752f03f3-b335-4ed7-a54b-2486f2c5d03e"),
+                            ApiMethod = "GET",
+                            Code = "system.rolepermission",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1248),
+                            Icon = "example",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "角色权限",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("23b39087-3df6-4338-b5c9-148dcd45e234"),
+                            ApiMethod = "GET",
+                            Code = "system.user.add",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1258),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "添加",
+                            ParentId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("cb9468e1-3e89-432b-8f66-61493a53d5ac"),
+                            ApiMethod = "GET",
+                            Code = "system.user.edit",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1261),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "编辑",
+                            ParentId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("9f732d16-a64b-4248-8264-2f4e334e3e01"),
+                            ApiMethod = "GET",
+                            Code = "system.user.delete",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1264),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "删除",
+                            ParentId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("795ab106-a9e0-4142-948d-2a709a0fd371"),
+                            ApiMethod = "GET",
+                            Code = "system.role.add",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1267),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "添加",
+                            ParentId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("14492003-3428-4a58-89a5-d91f2328b94f"),
+                            ApiMethod = "GET",
+                            Code = "system.role.edit",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1272),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "编辑",
+                            ParentId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("a950864b-283c-47a0-b931-2683a2c16ed5"),
+                            ApiMethod = "GET",
+                            Code = "system.role.delete",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1274),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "删除",
+                            ParentId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("58430242-3945-4b5a-b5cb-f58ab3d11fa1"),
+                            ApiMethod = "GET",
+                            Code = "system.permission.add",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1279),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "添加",
+                            ParentId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("668c187c-011f-4c93-ada8-b9612d01b285"),
+                            ApiMethod = "GET",
+                            Code = "system.permission.edit",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1284),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "编辑",
+                            ParentId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("139cdb4c-0b37-487b-a469-c42ca1179d73"),
+                            ApiMethod = "GET",
+                            Code = "system.permission.delete",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1286),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "删除",
+                            ParentId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("ea249c96-eb42-455c-8971-6d14897b250a"),
+                            ApiMethod = "GET",
+                            Code = "system.rolepermission.update",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1288),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "更新",
+                            ParentId = new Guid("752f03f3-b335-4ed7-a54b-2486f2c5d03e"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ConcurrencyStamp")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid?>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<DateTime?>("LastModificationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("LastModifierId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)");
+
+                    b.Property<string>("NormalizedName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)");
+
+                    b.Property<string>("Remark")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("Status")
+                        .HasColumnType("int");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CreationTime");
+
+                    b.HasIndex("NormalizedName");
+
+                    b.ToTable("EleRole", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            Id = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            ConcurrencyStamp = "640f42fdd96a4e4d827dc511cac97b79",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 575, DateTimeKind.Local).AddTicks(3124),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "管理员",
+                            NormalizedName = "管理员",
+                            Status = 1
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRoleClaim", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ClaimType")
+                        .IsRequired()
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("ClaimValue")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<Guid>("RoleId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("RoleId");
+
+                    b.ToTable("EleRoleClaim", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRolePermission", b =>
+                {
+                    b.Property<Guid>("RoleId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<Guid>("PermissionId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("RoleId", "PermissionId");
+
+                    b.HasIndex("PermissionId");
+
+                    b.HasIndex("RoleId", "PermissionId");
+
+                    b.ToTable("EleRolePermission", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1357),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1364),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1365),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1366),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("752f03f3-b335-4ed7-a54b-2486f2c5d03e"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1367),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("23b39087-3df6-4338-b5c9-148dcd45e234"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1368),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("cb9468e1-3e89-432b-8f66-61493a53d5ac"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1369),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("9f732d16-a64b-4248-8264-2f4e334e3e01"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1370),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("795ab106-a9e0-4142-948d-2a709a0fd371"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1371),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("14492003-3428-4a58-89a5-d91f2328b94f"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1372),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("a950864b-283c-47a0-b931-2683a2c16ed5"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1373),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("58430242-3945-4b5a-b5cb-f58ab3d11fa1"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1374),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("668c187c-011f-4c93-ada8-b9612d01b285"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1374),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("139cdb4c-0b37-487b-a469-c42ca1179d73"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1375),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("ea249c96-eb42-455c-8971-6d14897b250a"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1376),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<int>("AccessFailedCount")
+                        .HasColumnType("int")
+                        .HasColumnName("AccessFailedCount");
+
+                    b.Property<string>("ConcurrencyStamp")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid?>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Email")
+                        .HasColumnType("nvarchar(450)");
+
+                    b.Property<bool>("EmailConfirmed")
+                        .HasColumnType("bit");
+
+                    b.Property<string>("FullName")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("LastModificationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("LastModifierId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<bool>("LockoutEnabled")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bit")
+                        .HasDefaultValue(false)
+                        .HasColumnName("LockoutEnabled");
+
+                    b.Property<DateTimeOffset?>("LockoutEnd")
+                        .HasColumnType("datetimeoffset");
+
+                    b.Property<string>("NormalizedEmail")
+                        .IsRequired()
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)")
+                        .HasColumnName("NormalizedEmail");
+
+                    b.Property<string>("NormalizedUserName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)")
+                        .HasColumnName("NormalizedUserName");
+
+                    b.Property<string>("PasswordHash")
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)")
+                        .HasColumnName("PasswordHash");
+
+                    b.Property<string>("PhoneNumber")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<bool>("PhoneNumberConfirmed")
+                        .HasColumnType("bit");
+
+                    b.Property<string>("Remark")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("SecurityStamp")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)")
+                        .HasColumnName("SecurityStamp");
+
+                    b.Property<int>("Status")
+                        .HasColumnType("int");
+
+                    b.Property<bool>("TwoFactorEnabled")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bit")
+                        .HasDefaultValue(false)
+                        .HasColumnName("TwoFactorEnabled");
+
+                    b.Property<string>("UserName")
+                        .HasColumnType("nvarchar(450)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CreationTime");
+
+                    b.HasIndex("Email");
+
+                    b.HasIndex("NormalizedEmail");
+
+                    b.HasIndex("NormalizedUserName");
+
+                    b.HasIndex("UserName");
+
+                    b.ToTable("EleUser", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            Id = new Guid("0abd1739-7b72-4556-ad70-89009ecbcaa7"),
+                            AccessFailedCount = 0,
+                            ConcurrencyStamp = "de91e8a7e6da452998d003c0deed563d",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 575, DateTimeKind.Local).AddTicks(3428),
+                            Email = "admin@eletric.com",
+                            EmailConfirmed = true,
+                            FullName = "管理员",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            LockoutEnabled = false,
+                            NormalizedEmail = "ADMIN@ELETRIC.COM",
+                            NormalizedUserName = "ADMIN",
+                            PasswordHash = "AQAAAAIAAYagAAAAEIKewBYi6+6C2NweyM9RnBUliFXSc4zrK32BJWOzjIbVKdlE2p0MIcW5y5aYkQPBMw==",
+                            PhoneNumberConfirmed = false,
+                            SecurityStamp = "d31f0633-9dbc-4011-8620-04ccf42f5bf7",
+                            Status = 1,
+                            TwoFactorEnabled = false,
+                            UserName = "admin"
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserClaim", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ClaimType")
+                        .IsRequired()
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)");
+
+                    b.Property<string>("ClaimValue")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("UserId");
+
+                    b.ToTable("EleUserClaim", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserLogin", b =>
+                {
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("LoginProvider")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("ProviderDisplayName")
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)");
+
+                    b.Property<string>("ProviderKey")
+                        .IsRequired()
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.HasKey("UserId", "LoginProvider");
+
+                    b.HasIndex("LoginProvider", "ProviderKey");
+
+                    b.ToTable("EleUserLogin", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserRole", b =>
+                {
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<Guid>("RoleId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("UserId", "RoleId");
+
+                    b.HasIndex("RoleId", "UserId");
+
+                    b.ToTable("EleUserRole", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            UserId = new Guid("0abd1739-7b72-4556-ad70-89009ecbcaa7"),
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1121),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserToken", b =>
+                {
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("LoginProvider")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("Name")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("Value")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("UserId", "LoginProvider", "Name");
+
+                    b.ToTable("EleUserToken", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRoleClaim", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", null)
+                        .WithMany("Claims")
+                        .HasForeignKey("RoleId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRolePermission", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.ElePermission", null)
+                        .WithMany()
+                        .HasForeignKey("PermissionId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", null)
+                        .WithMany("Permissions")
+                        .HasForeignKey("RoleId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserClaim", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Claims")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserLogin", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Logins")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserRole", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", null)
+                        .WithMany()
+                        .HasForeignKey("RoleId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Roles")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserToken", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Tokens")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", b =>
+                {
+                    b.Navigation("Claims");
+
+                    b.Navigation("Permissions");
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", b =>
+                {
+                    b.Navigation("Claims");
+
+                    b.Navigation("Logins");
+
+                    b.Navigation("Roles");
+
+                    b.Navigation("Tokens");
+                });
+#pragma warning restore 612, 618
+        }
+    }
+}

Разница между файлами не показана из-за своего большого размера
+ 387 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Migrations/20240413234821_InitDB.cs


+ 806 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Migrations/ApplicationDbContextModelSnapshot.cs

@@ -0,0 +1,806 @@
+// <auto-generated />
+using System;
+using ECL142.BasicAuth.EntityFrameworkCore.Repository;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.DbMigrations.Migrations
+{
+    [DbContext(typeof(ApplicationDbContext))]
+    partial class ApplicationDbContextModelSnapshot : ModelSnapshot
+    {
+        protected override void BuildModel(ModelBuilder modelBuilder)
+        {
+#pragma warning disable 612, 618
+            modelBuilder
+                .HasAnnotation("ProductVersion", "8.0.4")
+                .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.ElePermission", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ApiMethod")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Code")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Component")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid?>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Icon")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("LastModificationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("LastModifierId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Name")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<Guid?>("ParentId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<int>("PermissionType")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Remark")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("Sort")
+                        .HasColumnType("int");
+
+                    b.Property<int>("Status")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Url")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CreationTime");
+
+                    b.ToTable("ElePermission", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            Id = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            ApiMethod = "GET",
+                            Code = "system",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1218),
+                            Icon = "el-icon-s-tools",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "系统管理",
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            ApiMethod = "GET",
+                            Code = "system.user",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1241),
+                            Icon = "el-icon-user-solid",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "用户管理",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            ApiMethod = "GET",
+                            Code = "system.role",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1244),
+                            Icon = "peoples",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "角色管理",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            ApiMethod = "GET",
+                            Code = "system.permission",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1245),
+                            Icon = "list",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "菜单管理",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("752f03f3-b335-4ed7-a54b-2486f2c5d03e"),
+                            ApiMethod = "GET",
+                            Code = "system.rolepermission",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1248),
+                            Icon = "example",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "角色权限",
+                            ParentId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            PermissionType = 0,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("23b39087-3df6-4338-b5c9-148dcd45e234"),
+                            ApiMethod = "GET",
+                            Code = "system.user.add",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1258),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "添加",
+                            ParentId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("cb9468e1-3e89-432b-8f66-61493a53d5ac"),
+                            ApiMethod = "GET",
+                            Code = "system.user.edit",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1261),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "编辑",
+                            ParentId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("9f732d16-a64b-4248-8264-2f4e334e3e01"),
+                            ApiMethod = "GET",
+                            Code = "system.user.delete",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1264),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "删除",
+                            ParentId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("795ab106-a9e0-4142-948d-2a709a0fd371"),
+                            ApiMethod = "GET",
+                            Code = "system.role.add",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1267),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "添加",
+                            ParentId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("14492003-3428-4a58-89a5-d91f2328b94f"),
+                            ApiMethod = "GET",
+                            Code = "system.role.edit",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1272),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "编辑",
+                            ParentId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("a950864b-283c-47a0-b931-2683a2c16ed5"),
+                            ApiMethod = "GET",
+                            Code = "system.role.delete",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1274),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "删除",
+                            ParentId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("58430242-3945-4b5a-b5cb-f58ab3d11fa1"),
+                            ApiMethod = "GET",
+                            Code = "system.permission.add",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1279),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "添加",
+                            ParentId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("668c187c-011f-4c93-ada8-b9612d01b285"),
+                            ApiMethod = "GET",
+                            Code = "system.permission.edit",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1284),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "编辑",
+                            ParentId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("139cdb4c-0b37-487b-a469-c42ca1179d73"),
+                            ApiMethod = "GET",
+                            Code = "system.permission.delete",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1286),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "删除",
+                            ParentId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        },
+                        new
+                        {
+                            Id = new Guid("ea249c96-eb42-455c-8971-6d14897b250a"),
+                            ApiMethod = "GET",
+                            Code = "system.rolepermission.update",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1288),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "更新",
+                            ParentId = new Guid("752f03f3-b335-4ed7-a54b-2486f2c5d03e"),
+                            PermissionType = 1,
+                            Sort = 0,
+                            Status = 1
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ConcurrencyStamp")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid?>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<DateTime?>("LastModificationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("LastModifierId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)");
+
+                    b.Property<string>("NormalizedName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)");
+
+                    b.Property<string>("Remark")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("Status")
+                        .HasColumnType("int");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CreationTime");
+
+                    b.HasIndex("NormalizedName");
+
+                    b.ToTable("EleRole", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            Id = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            ConcurrencyStamp = "640f42fdd96a4e4d827dc511cac97b79",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 575, DateTimeKind.Local).AddTicks(3124),
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            Name = "管理员",
+                            NormalizedName = "管理员",
+                            Status = 1
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRoleClaim", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ClaimType")
+                        .IsRequired()
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("ClaimValue")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<Guid>("RoleId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("RoleId");
+
+                    b.ToTable("EleRoleClaim", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRolePermission", b =>
+                {
+                    b.Property<Guid>("RoleId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<Guid>("PermissionId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("RoleId", "PermissionId");
+
+                    b.HasIndex("PermissionId");
+
+                    b.HasIndex("RoleId", "PermissionId");
+
+                    b.ToTable("EleRolePermission", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("1d4c0cd9-47e5-4de7-a523-8d74cb7a973b"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1357),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("09f1720e-bdd0-448d-9572-e0d1418fc4f8"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1364),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("f4af67e1-5614-4200-b4b9-edd5fe5d67b2"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1365),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("ae19a33d-79b2-4963-a992-febfc0ef1e58"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1366),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("752f03f3-b335-4ed7-a54b-2486f2c5d03e"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1367),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("23b39087-3df6-4338-b5c9-148dcd45e234"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1368),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("cb9468e1-3e89-432b-8f66-61493a53d5ac"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1369),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("9f732d16-a64b-4248-8264-2f4e334e3e01"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1370),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("795ab106-a9e0-4142-948d-2a709a0fd371"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1371),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("14492003-3428-4a58-89a5-d91f2328b94f"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1372),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("a950864b-283c-47a0-b931-2683a2c16ed5"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1373),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("58430242-3945-4b5a-b5cb-f58ab3d11fa1"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1374),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("668c187c-011f-4c93-ada8-b9612d01b285"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1374),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("139cdb4c-0b37-487b-a469-c42ca1179d73"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1375),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        },
+                        new
+                        {
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            PermissionId = new Guid("ea249c96-eb42-455c-8971-6d14897b250a"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1376),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<int>("AccessFailedCount")
+                        .HasColumnType("int")
+                        .HasColumnName("AccessFailedCount");
+
+                    b.Property<string>("ConcurrencyStamp")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid?>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("Email")
+                        .HasColumnType("nvarchar(450)");
+
+                    b.Property<bool>("EmailConfirmed")
+                        .HasColumnType("bit");
+
+                    b.Property<string>("FullName")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("LastModificationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("LastModifierId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<bool>("LockoutEnabled")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bit")
+                        .HasDefaultValue(false)
+                        .HasColumnName("LockoutEnabled");
+
+                    b.Property<DateTimeOffset?>("LockoutEnd")
+                        .HasColumnType("datetimeoffset");
+
+                    b.Property<string>("NormalizedEmail")
+                        .IsRequired()
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)")
+                        .HasColumnName("NormalizedEmail");
+
+                    b.Property<string>("NormalizedUserName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)")
+                        .HasColumnName("NormalizedUserName");
+
+                    b.Property<string>("PasswordHash")
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)")
+                        .HasColumnName("PasswordHash");
+
+                    b.Property<string>("PhoneNumber")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<bool>("PhoneNumberConfirmed")
+                        .HasColumnType("bit");
+
+                    b.Property<string>("Remark")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("SecurityStamp")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)")
+                        .HasColumnName("SecurityStamp");
+
+                    b.Property<int>("Status")
+                        .HasColumnType("int");
+
+                    b.Property<bool>("TwoFactorEnabled")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bit")
+                        .HasDefaultValue(false)
+                        .HasColumnName("TwoFactorEnabled");
+
+                    b.Property<string>("UserName")
+                        .HasColumnType("nvarchar(450)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("CreationTime");
+
+                    b.HasIndex("Email");
+
+                    b.HasIndex("NormalizedEmail");
+
+                    b.HasIndex("NormalizedUserName");
+
+                    b.HasIndex("UserName");
+
+                    b.ToTable("EleUser", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            Id = new Guid("0abd1739-7b72-4556-ad70-89009ecbcaa7"),
+                            AccessFailedCount = 0,
+                            ConcurrencyStamp = "de91e8a7e6da452998d003c0deed563d",
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 575, DateTimeKind.Local).AddTicks(3428),
+                            Email = "admin@eletric.com",
+                            EmailConfirmed = true,
+                            FullName = "管理员",
+                            LastModifierId = new Guid("00000000-0000-0000-0000-000000000000"),
+                            LockoutEnabled = false,
+                            NormalizedEmail = "ADMIN@ELETRIC.COM",
+                            NormalizedUserName = "ADMIN",
+                            PasswordHash = "AQAAAAIAAYagAAAAEIKewBYi6+6C2NweyM9RnBUliFXSc4zrK32BJWOzjIbVKdlE2p0MIcW5y5aYkQPBMw==",
+                            PhoneNumberConfirmed = false,
+                            SecurityStamp = "d31f0633-9dbc-4011-8620-04ccf42f5bf7",
+                            Status = 1,
+                            TwoFactorEnabled = false,
+                            UserName = "admin"
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserClaim", b =>
+                {
+                    b.Property<Guid>("Id")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("ClaimType")
+                        .IsRequired()
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)");
+
+                    b.Property<string>("ClaimValue")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("UserId");
+
+                    b.ToTable("EleUserClaim", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserLogin", b =>
+                {
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("LoginProvider")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("ProviderDisplayName")
+                        .HasMaxLength(100)
+                        .HasColumnType("nvarchar(100)");
+
+                    b.Property<string>("ProviderKey")
+                        .IsRequired()
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.HasKey("UserId", "LoginProvider");
+
+                    b.HasIndex("LoginProvider", "ProviderKey");
+
+                    b.ToTable("EleUserLogin", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserRole", b =>
+                {
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<Guid>("RoleId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<DateTime>("CreationTime")
+                        .HasColumnType("datetime2");
+
+                    b.Property<Guid>("CreatorId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.HasKey("UserId", "RoleId");
+
+                    b.HasIndex("RoleId", "UserId");
+
+                    b.ToTable("EleUserRole", (string)null);
+
+                    b.HasData(
+                        new
+                        {
+                            UserId = new Guid("0abd1739-7b72-4556-ad70-89009ecbcaa7"),
+                            RoleId = new Guid("bc35ed5e-61ac-4bb7-a57f-a2a768ff9bed"),
+                            CreationTime = new DateTime(2024, 4, 14, 7, 48, 20, 659, DateTimeKind.Local).AddTicks(1121),
+                            CreatorId = new Guid("00000000-0000-0000-0000-000000000000")
+                        });
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserToken", b =>
+                {
+                    b.Property<Guid>("UserId")
+                        .HasColumnType("uniqueidentifier");
+
+                    b.Property<string>("LoginProvider")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("Name")
+                        .HasMaxLength(200)
+                        .HasColumnType("nvarchar(200)");
+
+                    b.Property<string>("Value")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("UserId", "LoginProvider", "Name");
+
+                    b.ToTable("EleUserToken", (string)null);
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRoleClaim", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", null)
+                        .WithMany("Claims")
+                        .HasForeignKey("RoleId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRolePermission", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.ElePermission", null)
+                        .WithMany()
+                        .HasForeignKey("PermissionId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", null)
+                        .WithMany("Permissions")
+                        .HasForeignKey("RoleId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserClaim", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Claims")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserLogin", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Logins")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserRole", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", null)
+                        .WithMany()
+                        .HasForeignKey("RoleId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Roles")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUserToken", b =>
+                {
+                    b.HasOne("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", null)
+                        .WithMany("Tokens")
+                        .HasForeignKey("UserId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleRole", b =>
+                {
+                    b.Navigation("Claims");
+
+                    b.Navigation("Permissions");
+                });
+
+            modelBuilder.Entity("ECL142.BasicAuth.Domain.Entities.Identity.EleUser", b =>
+                {
+                    b.Navigation("Claims");
+
+                    b.Navigation("Logins");
+
+                    b.Navigation("Roles");
+
+                    b.Navigation("Tokens");
+                });
+#pragma warning restore 612, 618
+        }
+    }
+}

+ 30 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Program.cs

@@ -0,0 +1,30 @@
+using ECL142.BasicAuth.EntityFrameworkCore.DependencyInjection;
+
+using System.Reflection;
+
+var builder = WebApplication.CreateBuilder(args);
+
+//EntityFrameworkCoreע��
+var provider = builder.Configuration.GetValue<string>("DataProvider");
+var connection = string.Empty;
+
+//���õ����ݿ�����
+switch (provider)
+{
+    case "MsSql":
+        connection = builder.Configuration.GetConnectionString("MsSqlConnection") ?? throw new InvalidOperationException("MsSqlConnection��appsettings.json���");
+        break;
+
+    case "MySql":
+        connection = builder.Configuration.GetConnectionString("MySqlConnection") ?? throw new InvalidOperationException("MySqlConnection��appsettings.json���");
+        break;
+}
+
+//���ݿ�����
+var dbType = provider == "MySql" ? DbType.MySql : DbType.SqlServer;
+
+//, Assembly.GetExecutingAssembly().FullName
+builder.Services.AddEntityFrameworkCore(dbType, connection, Assembly.GetExecutingAssembly().FullName);
+
+var app = builder.Build();
+app.Run();

+ 31 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/Properties/launchSettings.json

@@ -0,0 +1,31 @@
+{
+  "$schema": "http://json.schemastore.org/launchsettings.json",
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:8037",
+      "sslPort": 0
+    }
+  },
+  "profiles": {
+    "http": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "launchUrl": "weatherforecast",
+      "applicationUrl": "http://localhost:5216",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": true,
+      "launchUrl": "weatherforecast",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 8 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}

+ 15 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore.DbMigrations/appsettings.json

@@ -0,0 +1,15 @@
+{ //数据库连接
+  "ConnectionStrings": {
+    "MsSqlConnection": "Server=localhost;Database=ElectricAuth;Uid=sa;Pwd=wyh_232321;TrustServerCertificate=true;",
+    "MySqlConnection": "Server=124.220.187.142;Database=ElectricAuth;Uid=eleven;Pwd=wyh_232321;"
+  },
+  //数据库:MsSql、MySql
+  "DataProvider": "MsSql",
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  },
+  "AllowedHosts": "*"
+}

+ 11 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/DependencyInjection/DbType.cs

@@ -0,0 +1,11 @@
+namespace ECL142.BasicAuth.EntityFrameworkCore.DependencyInjection
+{
+    /// <summary>
+    /// 自定义数据库类型
+    /// </summary>
+    public enum DbType
+    {
+        MySql = 0,
+        SqlServer = 1
+    }
+}

+ 81 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/DependencyInjection/ServiceCollectionExtensions.cs

@@ -0,0 +1,81 @@
+using ECL142.BasicAuth.Domain.Repositories;
+using ECL142.BasicAuth.EntityFrameworkCore.Repository;
+
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.DependencyInjection
+{
+    public static class ServiceCollectionExtensions
+    {
+        /// <summary>
+        /// EntityFrameworkCore注入
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="dbType"></param>
+        /// <param name="connection"></param>
+        /// <param name="assemblyName"></param>
+        public static void AddEntityFrameworkCore(this IServiceCollection services, DbType dbType, string connection, string? assemblyName = null)
+        {
+            #region 初始化数据库
+
+            // 如果当前程序集没有Migrations文件夹且没有快照时执行如下两步进行初始化数据库
+            //1.输入:Add-Migration InitDB,并回车。其中:Add-Migration为迁移命令,InitDB:这个是迁移的名称,可以根据自己自定义。
+            //2.在程序包管理器控制台,输入命令:Update-Database,并回车。
+
+            #endregion 初始化数据库
+
+            //Repository注入
+            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+            foreach (var assembly in assemblies)
+            {
+                //获取继承IRepository并且不是泛型的类
+                List<Type> types = assembly.GetTypes()
+                .Where(t => t.IsClass && !t.IsGenericType && t.GetInterfaces().Contains(typeof(IRepository)))
+                .ToList();
+
+                types.ForEach(impl =>
+                {
+                    //获取该类所继承的所有接口
+                    Type[] interfaces = impl.GetInterfaces();
+                    interfaces.ToList().ForEach(i =>
+                    {
+                        services.AddScoped(i, impl);
+                    });
+                });
+            }
+
+            //数据库上下文注入
+            services.AddDbContext<ApplicationDbContext>(options =>
+            {
+                //启用的数据库类型
+                switch (dbType)
+                {
+                    case DbType.SqlServer:
+                        if (assemblyName == null)
+                        {
+                            options.UseSqlServer(connection);
+                        }
+                        else
+                        {
+                            //AddEntityFrameworkCore增加一个参数:assemblyName,用来指定迁移程序集的名称。
+                            options.UseSqlServer(connection, b => b.MigrationsAssembly(assemblyName));
+                        }
+                        break;
+
+                    case DbType.MySql:
+                        if (assemblyName == null)
+                        {
+                            options.UseMySql(connection, ServerVersion.AutoDetect(connection));
+                        }
+                        else
+                        {
+                            //AddEntityFrameworkCore增加一个参数:assemblyName,用来指定迁移程序集的名称。
+                            options.UseMySql(connection, ServerVersion.AutoDetect(connection), b => b.MigrationsAssembly(assemblyName));
+                        }
+                        break;
+                }
+            });
+        }
+    }
+}

+ 19 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/ECL142.BasicAuth.EntityFrameworkCore.csproj

@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
+    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\ECL142.BasicAuth.Domain\ECL142.BasicAuth.Domain.csproj" />
+  </ItemGroup>
+
+</Project>

+ 282 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/ApplicationDbContext.cs

@@ -0,0 +1,282 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Shared.Entities.Identity;
+using ECL142.BasicAuth.Domain.Shared.Entities;
+
+using Microsoft.AspNetCore.Identity;
+using Microsoft.EntityFrameworkCore;
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.Repository
+{
+    /// <summary>
+    /// 数据库上下文
+    /// </summary>
+    public class ApplicationDbContext : DbContext
+    {
+        /// <summary>
+        /// 权限
+        /// </summary>
+        public DbSet<ElePermission> Permissions { get; set; }
+
+        /// <summary>
+        /// 用户
+        /// </summary>
+        public DbSet<EleUser> Users { get; set; }
+
+        /// <summary>
+        /// 用户声明
+        /// </summary>
+        public DbSet<EleUserClaim> UserClaims { get; set; }
+
+        /// <summary>
+        /// 登录信息
+        /// </summary>
+        public DbSet<EleUserLogin> UserLogins { get; set; }
+
+        /// <summary>
+        /// 用户角色
+        /// </summary>
+        public DbSet<EleUserRole> UserRoles { get; set; }
+
+        /// <summary>
+        /// 令牌
+        /// </summary>
+        public DbSet<EleUserToken> UserTokens { get; set; }
+
+        /// <summary>
+        /// 角色
+        /// </summary>
+        public DbSet<EleRole> Roles { get; set; }
+
+        /// <summary>
+        /// 角色声明
+        /// </summary>
+        public DbSet<EleRoleClaim> RoleClaims { get; set; }
+
+        /// <summary>
+        /// 角色权限
+        /// </summary>
+        public DbSet<EleRolePermission> RolePermissions { get; set; }
+
+        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
+        {
+        }
+
+        protected override void OnModelCreating(ModelBuilder modelBuilder)
+        {
+            base.OnModelCreating(modelBuilder);
+
+            ConfigureEntityTables(modelBuilder);
+
+            AddSeedData(modelBuilder);
+        }
+
+        /// <summary>
+        /// 配置实体映射表
+        /// </summary>
+        /// <param name="modelBuilder"></param>
+        private void ConfigureEntityTables(ModelBuilder modelBuilder)
+        {
+            // 配置实体类型映射到的表名
+            modelBuilder.Entity<EleUser>(b =>
+            {
+                b.ToTable("EleUser");
+                b.HasKey(x => x.Id);
+
+                b.Property(u => u.NormalizedUserName).IsRequired()
+                    .HasMaxLength(50)
+                    .HasColumnName(nameof(EleUser.NormalizedUserName));
+                b.Property(u => u.NormalizedEmail).IsRequired()
+                    .HasMaxLength(100)
+                    .HasColumnName(nameof(EleUser.NormalizedEmail));
+                b.Property(u => u.PasswordHash).HasMaxLength(100)
+                    .HasColumnName(nameof(EleUser.PasswordHash));
+                b.Property(u => u.SecurityStamp).IsRequired().HasMaxLength(50)
+                    .HasColumnName(nameof(EleUser.SecurityStamp));
+                b.Property(u => u.TwoFactorEnabled).HasDefaultValue(false)
+                    .HasColumnName(nameof(EleUser.TwoFactorEnabled));
+                b.Property(u => u.LockoutEnabled).HasDefaultValue(false)
+                    .HasColumnName(nameof(EleUser.LockoutEnabled));
+
+                b.Property(u => u.AccessFailedCount)
+                    .HasColumnName(nameof(EleUser.AccessFailedCount));
+
+                b.HasMany(u => u.Claims).WithOne().HasForeignKey(uc => uc.UserId).IsRequired();
+                b.HasMany(u => u.Logins).WithOne().HasForeignKey(ul => ul.UserId).IsRequired();
+                b.HasMany(u => u.Roles).WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
+                b.HasMany(u => u.Tokens).WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
+
+                b.HasIndex(u => u.NormalizedUserName);
+                b.HasIndex(u => u.NormalizedEmail);
+                b.HasIndex(u => u.UserName);
+                b.HasIndex(u => u.Email);
+                b.HasIndex(u => u.CreationTime);
+            });
+
+            modelBuilder.Entity<EleUserClaim>(b =>
+            {
+                b.ToTable("EleUserClaim");
+
+                b.Property(x => x.Id).ValueGeneratedNever();
+
+                b.Property(uc => uc.ClaimType).HasMaxLength(100).IsRequired();
+                b.Property(uc => uc.ClaimValue).HasMaxLength(200);
+
+                b.HasIndex(uc => uc.UserId);
+            });
+
+            modelBuilder.Entity<EleUserRole>(b =>
+            {
+                b.ToTable("EleUserRole");
+
+                b.HasKey(ur => new { ur.UserId, ur.RoleId });
+
+                b.HasOne<EleRole>().WithMany().HasForeignKey(ur => ur.RoleId).IsRequired();
+                b.HasOne<EleUser>().WithMany(u => u.Roles).HasForeignKey(ur => ur.UserId).IsRequired();
+
+                b.HasIndex(ur => new { ur.RoleId, ur.UserId });
+            });
+
+            modelBuilder.Entity<EleUserLogin>(b =>
+            {
+                b.ToTable("EleUserLogin");
+
+                b.HasKey(x => new { x.UserId, x.LoginProvider });
+
+                b.Property(ul => ul.LoginProvider).HasMaxLength(200)
+                    .IsRequired();
+                b.Property(ul => ul.ProviderKey).HasMaxLength(200)
+                    .IsRequired();
+                b.Property(ul => ul.ProviderDisplayName)
+                    .HasMaxLength(100);
+
+                b.HasIndex(l => new { l.LoginProvider, l.ProviderKey });
+            });
+
+            modelBuilder.Entity<EleUserToken>(b =>
+            {
+                b.ToTable("EleUserToken");
+
+                b.HasKey(l => new { l.UserId, l.LoginProvider, l.Name });
+
+                b.Property(ul => ul.LoginProvider).HasMaxLength(200)
+                    .IsRequired();
+                b.Property(ul => ul.Name).HasMaxLength(200).IsRequired();
+            });
+
+            modelBuilder.Entity<EleRole>(b =>
+            {
+                b.ToTable("EleRole");
+                b.HasKey(x => x.Id);
+                b.Property(r => r.Name).IsRequired().HasMaxLength(50);
+                b.Property(r => r.NormalizedName).IsRequired().HasMaxLength(50);
+                b.HasMany(r => r.Claims).WithOne().HasForeignKey(rc => rc.RoleId).IsRequired();
+                //指定角色与角色权限表,一对多
+                b.HasMany(r => r.Permissions).WithOne().HasForeignKey(x => x.RoleId).IsRequired();
+
+                b.HasIndex(r => r.NormalizedName);
+                b.HasIndex(u => u.CreationTime);
+            });
+
+            modelBuilder.Entity<EleRoleClaim>(b =>
+            {
+                b.ToTable("EleRoleClaim");
+
+                b.Property(x => x.Id).ValueGeneratedNever();
+
+                b.Property(uc => uc.ClaimType).HasMaxLength(200).IsRequired();
+                b.Property(uc => uc.ClaimValue).HasMaxLength(200);
+
+                b.HasIndex(uc => uc.RoleId);
+            });
+            modelBuilder.Entity<ElePermission>(b =>
+            {
+                b.ToTable("ElePermission");
+                b.HasKey(x => x.Id);
+                b.HasIndex(u => u.CreationTime);
+            });
+            modelBuilder.Entity<EleRolePermission>(b =>
+            {
+                b.ToTable("EleRolePermission");
+                b.HasKey(rp => new { rp.RoleId, rp.PermissionId });
+
+                b.HasOne<EleRole>().WithMany(r => r.Permissions).HasForeignKey(r => r.RoleId).IsRequired();
+                b.HasOne<ElePermission>().WithMany().HasForeignKey(ur => ur.PermissionId).IsRequired();
+
+                b.HasIndex(rp => new { rp.RoleId, rp.PermissionId });
+            });
+        }
+
+        /// <summary>
+        /// 添加种子数据
+        /// </summary>
+        /// <param name="modelBuilder"></param>
+        private void AddSeedData(ModelBuilder modelBuilder)
+        {
+            //1. 角色Id
+            var adminRoleId = Guid.NewGuid();
+            // 2. 添加角色
+            modelBuilder.Entity<EleRole>().HasData(
+                new EleRole(adminRoleId, "管理员")
+            );
+
+            // 3. 添加用户
+            var adminUserId = Guid.NewGuid();
+            EleUser adminUser = new EleUser(adminUserId, "admin", "admin@eletric.com", "管理员");
+            var ph = new PasswordHasher<EleUser>();
+            var passwordHash = ph.HashPassword(adminUser, "Abc123@");
+            adminUser.SetPasswordHash(passwordHash);
+            modelBuilder.Entity<EleUser>().HasData(adminUser);
+
+            // 4. 给用户加入管理员权限
+            modelBuilder.Entity<EleUserRole>()
+                .HasData(new EleUserRole(adminUserId, adminRoleId));
+
+            //5. 初始化权限
+            var systemId = Guid.NewGuid();
+            var systemUserId = Guid.NewGuid();
+            var systemRoleId = Guid.NewGuid();
+            var systemPermissionId = Guid.NewGuid();
+            var systemRolePermissionId = Guid.NewGuid();
+            var permissionList = new List<ElePermission>
+    {
+        #region 菜单权限
+
+        new ElePermission(systemId, null,"系统管理",  "system", PermissionType.Menu, PermissionApiMethod.GET, PermissionStatus.Normal, icon: "el-icon-s-tools"),
+        new ElePermission(systemUserId,systemId,"用户管理",  "system.user", PermissionType.Menu, PermissionApiMethod.GET, PermissionStatus.Normal, "el-icon-user-solid"),
+        new ElePermission(systemRoleId, systemId, "角色管理", "system.role", PermissionType.Menu, PermissionApiMethod.GET, PermissionStatus.Normal, "peoples"),
+        new ElePermission(systemPermissionId, systemId, "菜单管理", "system.permission", PermissionType.Menu, PermissionApiMethod.GET, PermissionStatus.Normal, "list"),
+        new ElePermission(systemRolePermissionId, systemId, "角色权限", "system.rolepermission", PermissionType.Menu, PermissionApiMethod.GET, PermissionStatus.Normal, "example"),
+
+        #endregion 菜单权限
+
+        #region 按钮、元素权限
+
+        new ElePermission(Guid.NewGuid(),systemUserId, "添加",  "system.user.add", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+        new ElePermission(Guid.NewGuid(), systemUserId, "编辑", "system.user.edit", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+        new ElePermission(Guid.NewGuid(), systemUserId, "删除", "system.user.delete", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+
+        new ElePermission(Guid.NewGuid(), systemRoleId, "添加", "system.role.add", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+        new ElePermission(Guid.NewGuid(), systemRoleId, "编辑", "system.role.edit", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+        new ElePermission(Guid.NewGuid(), systemRoleId, "删除", "system.role.delete", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+
+         new ElePermission(Guid.NewGuid(), systemPermissionId, "添加", "system.permission.add", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+        new ElePermission(Guid.NewGuid(), systemPermissionId, "编辑", "system.permission.edit", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+        new ElePermission(Guid.NewGuid(), systemPermissionId, "删除", "system.permission.delete", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+
+        new ElePermission(Guid.NewGuid(), systemRolePermissionId, "更新", "system.rolepermission.update", PermissionType.Element, PermissionApiMethod.GET, PermissionStatus.Normal),
+
+        #endregion 按钮、元素权限
+    };
+            modelBuilder.Entity<ElePermission>().HasData(permissionList);
+
+            // 6. 给角色分配权限
+            var rolePermissionList = new List<EleRolePermission>();
+            foreach (var permission in permissionList)
+            {
+                rolePermissionList.Add(new EleRolePermission(adminRoleId, permission.Id));
+            }
+            modelBuilder.Entity<EleRolePermission>()
+                .HasData(rolePermissionList);
+        }
+    }
+}

+ 84 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/EfCoreRepository.cs

@@ -0,0 +1,84 @@
+using ECL142.BasicAuth.Domain.Entities.Commons;
+using ECL142.BasicAuth.Domain.Repositories;
+using System.Linq.Expressions;
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.Repository
+{
+    /// <summary>
+    /// 基础仓储
+    /// </summary>
+    /// <typeparam name="TEntity"></typeparam>
+    /// <typeparam name="TKey"></typeparam>
+    public class EfCoreRepository<TEntity, TKey> : IBasicRepository<TEntity, TKey> where TEntity : Entity<TKey>
+    {
+        public Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task DeleteManyAsync(IEnumerable<TKey> ids, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<long> GetCountAsync(CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<long> GetCountAsync(Expression<Func<TEntity, bool>> filter, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> filter, int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 11 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/Identity/EFCorePermissionRepository.cs

@@ -0,0 +1,11 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Repositories.Identity;
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.Repository.Identity
+{
+    /// 权限仓储
+    /// </summary>
+    public class EFCorePermissionRepository : EfCoreRepository<ElePermission, Guid>, IPermissionRepository
+    {
+    }
+}

+ 16 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/Identity/EFCoreRoleRepository.cs

@@ -0,0 +1,16 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Repositories.Identity;
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.Repository.Identity
+{
+    /// <summary>
+    /// 角色仓储
+    /// </summary>
+    public class EFCoreRoleRepository : EfCoreRepository<EleRole, Guid>, IRoleRepository
+    {
+        public Task<EleRole> FindByNameAsync(string roleName, bool includeDetails = true, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 26 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.EntityFrameworkCore/Repository/Identity/EFCoreUserRepository.cs

@@ -0,0 +1,26 @@
+using ECL142.BasicAuth.Domain.Entities.Identity;
+using ECL142.BasicAuth.Domain.Repositories.Identity;
+
+namespace ECL142.BasicAuth.EntityFrameworkCore.Repository.Identity
+{
+    /// <summary>
+    /// 用户仓储
+    /// </summary>
+    public class EFCoreUserRepository : EfCoreRepository<EleUser, Guid>, IUserRepository
+    {
+        public Task<EleUser> FindByNameAsync(string userName, bool includeDetails = true, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<EleUser>> GetListByRoleNameAsync(string roleName, bool includeDetails = true, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+
+        public Task<List<string>> GetRoleNamesAsync(Guid id, CancellationToken cancellationToken = default)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 33 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.WebAPI/Controllers/WeatherForecastController.cs

@@ -0,0 +1,33 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace ECL142.BasicAuth.WebAPI.Controllers
+{
+    [ApiController]
+    [Route("[controller]")]
+    public class WeatherForecastController : ControllerBase
+    {
+        private static readonly string[] Summaries = new[]
+        {
+            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
+        };
+
+        private readonly ILogger<WeatherForecastController> _logger;
+
+        public WeatherForecastController(ILogger<WeatherForecastController> logger)
+        {
+            _logger = logger;
+        }
+
+        [HttpGet(Name = "GetWeatherForecast")]
+        public IEnumerable<WeatherForecast> Get()
+        {
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+            {
+                Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
+                TemperatureC = Random.Shared.Next(-20, 55),
+                Summary = Summaries[Random.Shared.Next(Summaries.Length)]
+            })
+            .ToArray();
+        }
+    }
+}

+ 21 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.WebAPI/ECL142.BasicAuth.WebAPI.csproj

@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>net8.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <InvariantGlobalization>true</InvariantGlobalization>
+    <GenerateDocumentationFile>True</GenerateDocumentationFile>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\ECL142.BasicAuth.Application\ECL142.BasicAuth.Application.csproj" />
+    <ProjectReference Include="..\ECL142.BasicAuth.Domain\ECL142.BasicAuth.Domain.csproj" />
+    <ProjectReference Include="..\ECL142.BasicAuth.EntityFrameworkCore\ECL142.BasicAuth.EntityFrameworkCore.csproj" />
+  </ItemGroup>
+
+</Project>

+ 0 - 0
src/ECL142.BasicAuth/ECL142.BasicAuth.WebAPI/ECL142.BasicAuth.WebAPI.http


Некоторые файлы не были показаны из-за большого количества измененных файлов