From b0a379f9b2c7d76074f247cfdb580003c1d37630 Mon Sep 17 00:00:00 2001 From: root <295172551@qq.com> Date: Fri, 16 May 2025 21:22:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BB=A5=E7=AC=A6=E5=90=88DDD=E6=9E=B6=E6=9E=84=20-?= =?UTF-8?q?=20=E5=B0=86OperationResult=E8=BF=81=E7=A7=BB=E5=88=B0=E9=A2=86?= =?UTF-8?q?=E5=9F=9F=E5=B1=82=20-=20=E4=BC=98=E5=8C=96=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BD=8D=E7=BD=AE=20-=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E6=B3=A8=E5=85=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Behaviours/ValidationBehaviour.cs | 1 + .../DependencyInjection.cs | 2 + .../AuthenticateUserCommand.cs | 1 + .../AuthenticateUserCommandHandler.cs | 8 +- .../AuthenticateUserResponse.cs | 1 + .../RefreshToken/RefreshTokenCommand.cs | 1 + .../RefreshTokenCommandHandler.cs | 8 +- .../RegisterUser/RegisterUserCommand.cs | 1 + .../RegisterUserCommandHandler.cs | 5 + .../Features/Auth/Common/UserInfo.cs | 2 + .../CreatePermissionCommand.cs | 1 + .../CreatePermissionCommandHandler.cs | 2 + .../AddRolePermissionsCommand.cs | 2 + .../AddRolePermissionsCommandHandler.cs | 5 + .../DeleteRolePermissionsCommand.cs | 2 + .../DeleteRolePermissionsCommandHandler.cs | 5 + .../GetRolePermissionsQuery.cs | 1 + .../GetRolePermissionsQueryHandler.cs | 5 + .../GetRolePermissionsResponse.cs | 1 + .../Commands/CreateRole/CreateRoleCommand.cs | 1 + .../Commands/DeleteRole/DeleteRoleCommand.cs | 1 + .../Roles/Commands/RoleCommandHandler.cs | 5 + .../Roles/Queries/GetAllRolesQuery.cs | 3 + .../Roles/Queries/GetRole/GetRoleQuery.cs | 1 + .../Roles/Queries/GetRole/GetRoleResponse.cs | 2 + .../Roles/Queries/RoleQueryHandler.cs | 5 + .../Commands/CreateUser/CreateUserCommand.cs | 1 + .../CreateUser/CreateUserCommandHandler.cs | 5 + .../Commands/DeleteUser/DeleteUserCommand.cs | 1 + .../DeleteUser/DeleteUserCommandHandler.cs | 5 + .../Commands/UpdateUser/UpdateUserCommand.cs | 1 + .../UpdateUser/UpdateUserCommandHandler.cs | 5 + .../Queries/GetAllUsers/GetAllUsersQuery.cs | 1 + .../GetAllUsers/GetAllUsersQueryHandler.cs | 5 + .../GetAllUsers/GetAllUsersResponse.cs | 2 + .../Queries/GetUserById/GetUserByIdQuery.cs | 1 + .../GetUserById/GetUserByIdQueryHandler.cs | 4 + .../Common/OperationResult.cs | 7 +- .../Services/ICacheService.cs | 3 +- .../Services/IEmailService.cs | 33 +++++ .../Services/IEmailVerificationService.cs | 25 ++++ .../Services/IJwtProvider.cs | 3 +- .../Services/IKeyRotationService.cs | 3 +- .../DependencyInjection.cs | 7 +- .../Options/EmailOptions.cs | 42 ++++++ .../Services/CacheService.cs | 3 +- .../Services/EmailService.cs | 116 +++++++++++++++ .../Services/EmailVerificationService.cs | 132 ++++++++++++++++++ .../Services/JwtProvider.cs | 2 +- .../Services/KeyRotationBackgroundService.cs | 2 +- .../Services/KeyRotationService.cs | 2 +- .../Controllers/AuthController.cs | 3 +- .../Controllers/PermissionsController.cs | 1 + .../Controllers/RolePermissionController.cs | 1 + .../Controllers/RolesController.cs | 1 + .../Controllers/UsersController.cs | 3 +- .../appsettings.json | 17 +++ 57 files changed, 496 insertions(+), 13 deletions(-) rename src/{CellularManagement.Application => CellularManagement.Domain}/Common/OperationResult.cs (95%) rename src/{CellularManagement.Application => CellularManagement.Domain}/Services/ICacheService.cs (94%) create mode 100644 src/CellularManagement.Domain/Services/IEmailService.cs create mode 100644 src/CellularManagement.Domain/Services/IEmailVerificationService.cs rename src/{CellularManagement.Application => CellularManagement.Domain}/Services/IJwtProvider.cs (97%) rename src/{CellularManagement.Application => CellularManagement.Domain}/Services/IKeyRotationService.cs (86%) create mode 100644 src/CellularManagement.Infrastructure/Options/EmailOptions.cs create mode 100644 src/CellularManagement.Infrastructure/Services/EmailService.cs create mode 100644 src/CellularManagement.Infrastructure/Services/EmailVerificationService.cs create mode 100644 src/CellularManagement.Presentation/appsettings.json diff --git a/src/CellularManagement.Application/Behaviours/ValidationBehaviour.cs b/src/CellularManagement.Application/Behaviours/ValidationBehaviour.cs index a55336f..c268efa 100644 --- a/src/CellularManagement.Application/Behaviours/ValidationBehaviour.cs +++ b/src/CellularManagement.Application/Behaviours/ValidationBehaviour.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading; diff --git a/src/CellularManagement.Application/DependencyInjection.cs b/src/CellularManagement.Application/DependencyInjection.cs index 7b37cbc..38f6ffb 100644 --- a/src/CellularManagement.Application/DependencyInjection.cs +++ b/src/CellularManagement.Application/DependencyInjection.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using MediatR; using FluentValidation; using CellularManagement.Application.Behaviours; +using CellularManagement.Domain.Services; namespace CellularManagement.Application; @@ -33,6 +34,7 @@ public static class DependencyInjection // 注册验证器 services.AddScoped(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>)); + return services; } } \ No newline at end of file diff --git a/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommand.cs b/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommand.cs index a3ccd97..64aa811 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommand.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Auth.Commands.AuthenticateUser; diff --git a/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommandHandler.cs b/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommandHandler.cs index 00f8f1c..8e63c91 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserCommandHandler.cs @@ -3,10 +3,16 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using MediatR; using CellularManagement.Application.Common; -using CellularManagement.Application.Services; using CellularManagement.Domain.Entities; using CellularManagement.Application.Features.Auth.Common; using CellularManagement.Domain.Repositories; +using CellularManagement.Domain.Services; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System; +using CellularManagement.Domain.Common; namespace CellularManagement.Application.Features.Auth.Commands.AuthenticateUser; diff --git a/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserResponse.cs b/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserResponse.cs index fd4005b..e11c6ba 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserResponse.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/AuthenticateUser/AuthenticateUserResponse.cs @@ -1,3 +1,4 @@ +using System; using CellularManagement.Application.Features.Auth.Common; namespace CellularManagement.Application.Features.Auth.Commands.AuthenticateUser; diff --git a/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommand.cs b/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommand.cs index 4509331..45d82b7 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommand.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommand.cs @@ -1,6 +1,7 @@ using MediatR; using System.ComponentModel.DataAnnotations; using CellularManagement.Application.Features.Auth.Commands.AuthenticateUser; +using CellularManagement.Domain.Common; namespace CellularManagement.Application.Features.Auth.Commands.RefreshToken; diff --git a/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommandHandler.cs b/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommandHandler.cs index 78267f6..8dcd7cc 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/RefreshToken/RefreshTokenCommandHandler.cs @@ -1,11 +1,17 @@ using MediatR; using Microsoft.Extensions.Logging; using CellularManagement.Application.Common; -using CellularManagement.Application.Services; using System.Security.Claims; using CellularManagement.Application.Features.Auth.Commands.AuthenticateUser; using CellularManagement.Application.Features.Auth.Common; using CellularManagement.Domain.Repositories; +using CellularManagement.Domain.Services; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System.Collections.Generic; +using System; +using CellularManagement.Domain.Common; namespace CellularManagement.Application.Features.Auth.Commands.RefreshToken; diff --git a/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommand.cs b/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommand.cs index 7c62d0f..7e17e0c 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommand.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Auth.Commands.RegisterUser; diff --git a/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommandHandler.cs b/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommandHandler.cs index 9f05e34..3fb9b57 100644 --- a/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Auth/Commands/RegisterUser/RegisterUserCommandHandler.cs @@ -4,6 +4,11 @@ using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; using Microsoft.Extensions.Options; +using CellularManagement.Domain.Common; +using System.Linq; +using System; +using System.Threading.Tasks; +using System.Threading; namespace CellularManagement.Application.Features.Auth.Commands.RegisterUser; diff --git a/src/CellularManagement.Application/Features/Auth/Common/UserInfo.cs b/src/CellularManagement.Application/Features/Auth/Common/UserInfo.cs index 4f9613e..70652c4 100644 --- a/src/CellularManagement.Application/Features/Auth/Common/UserInfo.cs +++ b/src/CellularManagement.Application/Features/Auth/Common/UserInfo.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace CellularManagement.Application.Features.Auth.Common; /// diff --git a/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommand.cs b/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommand.cs index 9be68fc..ac17f91 100644 --- a/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommand.cs +++ b/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommand.cs @@ -1,5 +1,6 @@ using MediatR; using CellularManagement.Application.Common; +using CellularManagement.Domain.Common; namespace CellularManagement.Application.Features.Permissions.Commands.CreatePermission; diff --git a/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommandHandler.cs b/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommandHandler.cs index b91bfd2..9147bf4 100644 --- a/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Permissions/Commands/CreatePermission/CreatePermissionCommandHandler.cs @@ -5,6 +5,8 @@ using Microsoft.Extensions.Logging; using CellularManagement.Application.Common; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; +using CellularManagement.Domain.Common; +using System; namespace CellularManagement.Application.Features.Permissions.Commands.CreatePermission; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommand.cs b/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommand.cs index 8b5f5f8..dc78d1a 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommand.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommand.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.RolePermissions.Commands.AddRolePermissions; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommandHandler.cs b/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommandHandler.cs index 0cfa329..6cbb6e4 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommandHandler.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Commands/AddRolePermissions/AddRolePermissionsCommandHandler.cs @@ -1,6 +1,11 @@ using MediatR; using CellularManagement.Domain.Repositories; using Microsoft.Extensions.Logging; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System; +using System.Linq; namespace CellularManagement.Application.Features.RolePermissions.Commands.AddRolePermissions; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommand.cs b/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommand.cs index cafa72d..e4969f2 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommand.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommand.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.RolePermissions.Commands.DeleteRolePermissions; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommandHandler.cs b/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommandHandler.cs index f0cf191..61abc24 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommandHandler.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Commands/DeleteRolePermissions/DeleteRolePermissionsCommandHandler.cs @@ -1,6 +1,11 @@ using MediatR; using CellularManagement.Domain.Repositories; using Microsoft.Extensions.Logging; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System; namespace CellularManagement.Application.Features.RolePermissions.Commands.DeleteRolePermissions; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQuery.cs b/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQuery.cs index b639413..a3a09c4 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQuery.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQuery.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.RolePermissions.Queries.GetRolePermissions; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQueryHandler.cs b/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQueryHandler.cs index 35d4661..a4d9035 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQueryHandler.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsQueryHandler.cs @@ -1,6 +1,11 @@ using MediatR; using CellularManagement.Domain.Repositories; using Microsoft.Extensions.Logging; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System; namespace CellularManagement.Application.Features.RolePermissions.Queries.GetRolePermissions; diff --git a/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsResponse.cs b/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsResponse.cs index a64683e..a2382a8 100644 --- a/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsResponse.cs +++ b/src/CellularManagement.Application/Features/RolePermissions/Queries/GetRolePermissions/GetRolePermissionsResponse.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using CellularManagement.Domain.Entities; namespace CellularManagement.Application.Features.RolePermissions.Queries.GetRolePermissions; diff --git a/src/CellularManagement.Application/Features/Roles/Commands/CreateRole/CreateRoleCommand.cs b/src/CellularManagement.Application/Features/Roles/Commands/CreateRole/CreateRoleCommand.cs index 9c161a3..38379b2 100644 --- a/src/CellularManagement.Application/Features/Roles/Commands/CreateRole/CreateRoleCommand.cs +++ b/src/CellularManagement.Application/Features/Roles/Commands/CreateRole/CreateRoleCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Roles.Commands.CreateRole; diff --git a/src/CellularManagement.Application/Features/Roles/Commands/DeleteRole/DeleteRoleCommand.cs b/src/CellularManagement.Application/Features/Roles/Commands/DeleteRole/DeleteRoleCommand.cs index ac2e38c..65f9a04 100644 --- a/src/CellularManagement.Application/Features/Roles/Commands/DeleteRole/DeleteRoleCommand.cs +++ b/src/CellularManagement.Application/Features/Roles/Commands/DeleteRole/DeleteRoleCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Roles.Commands.DeleteRole; diff --git a/src/CellularManagement.Application/Features/Roles/Commands/RoleCommandHandler.cs b/src/CellularManagement.Application/Features/Roles/Commands/RoleCommandHandler.cs index 92d6e20..b604a42 100644 --- a/src/CellularManagement.Application/Features/Roles/Commands/RoleCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Roles/Commands/RoleCommandHandler.cs @@ -4,6 +4,11 @@ using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Application.Features.Roles.Commands.CreateRole; using CellularManagement.Application.Features.Roles.Commands.DeleteRole; +using CellularManagement.Domain.Common; +using System.Linq; +using System; +using System.Threading; +using System.Threading.Tasks; namespace CellularManagement.Application.Features.Roles.Commands; diff --git a/src/CellularManagement.Application/Features/Roles/Queries/GetAllRolesQuery.cs b/src/CellularManagement.Application/Features/Roles/Queries/GetAllRolesQuery.cs index 97e8e9e..016b06a 100644 --- a/src/CellularManagement.Application/Features/Roles/Queries/GetAllRolesQuery.cs +++ b/src/CellularManagement.Application/Features/Roles/Queries/GetAllRolesQuery.cs @@ -1,5 +1,8 @@ using MediatR; using CellularManagement.Application.Common; +using System; +using CellularManagement.Domain.Common; +using System.Collections.Generic; namespace CellularManagement.Application.Features.Roles.Queries; diff --git a/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleQuery.cs b/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleQuery.cs index defe13e..fe434e5 100644 --- a/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleQuery.cs +++ b/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleQuery.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Roles.Queries.GetRole; diff --git a/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleResponse.cs b/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleResponse.cs index 68676f5..26e1307 100644 --- a/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleResponse.cs +++ b/src/CellularManagement.Application/Features/Roles/Queries/GetRole/GetRoleResponse.cs @@ -1,3 +1,5 @@ +using System; + namespace CellularManagement.Application.Features.Roles.Queries.GetRole; /// diff --git a/src/CellularManagement.Application/Features/Roles/Queries/RoleQueryHandler.cs b/src/CellularManagement.Application/Features/Roles/Queries/RoleQueryHandler.cs index 2167853..e52c83c 100644 --- a/src/CellularManagement.Application/Features/Roles/Queries/RoleQueryHandler.cs +++ b/src/CellularManagement.Application/Features/Roles/Queries/RoleQueryHandler.cs @@ -5,6 +5,11 @@ using CellularManagement.Domain.Entities; using CellularManagement.Application.Features.Roles.Queries.GetRole; using CellularManagement.Application.Features.Roles.Queries; using Microsoft.EntityFrameworkCore; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System; +using System.Linq; namespace CellularManagement.Application.Features.Roles.Queries; diff --git a/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommand.cs b/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommand.cs index b0a7235..69c462b 100644 --- a/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommand.cs +++ b/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Users.Commands.CreateUser; diff --git a/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommandHandler.cs b/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommandHandler.cs index 18cb965..43f0e4a 100644 --- a/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Users/Commands/CreateUser/CreateUserCommandHandler.cs @@ -3,6 +3,11 @@ using Microsoft.Extensions.Logging; using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System; +using System.Linq; namespace CellularManagement.Application.Features.Users.Commands.CreateUser; diff --git a/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommand.cs b/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommand.cs index cbacb81..736c088 100644 --- a/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommand.cs +++ b/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Users.Commands.DeleteUser; diff --git a/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommandHandler.cs b/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommandHandler.cs index ef0e2ad..244da38 100644 --- a/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Users/Commands/DeleteUser/DeleteUserCommandHandler.cs @@ -3,6 +3,11 @@ using Microsoft.Extensions.Logging; using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System; namespace CellularManagement.Application.Features.Users.Commands.DeleteUser; diff --git a/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommand.cs b/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommand.cs index 63ddb64..f07e129 100644 --- a/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommand.cs +++ b/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommand.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Users.Commands.UpdateUser; diff --git a/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommandHandler.cs b/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommandHandler.cs index 8e5eef7..42bb42b 100644 --- a/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommandHandler.cs +++ b/src/CellularManagement.Application/Features/Users/Commands/UpdateUser/UpdateUserCommandHandler.cs @@ -3,6 +3,11 @@ using Microsoft.Extensions.Logging; using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System; namespace CellularManagement.Application.Features.Users.Commands.UpdateUser; diff --git a/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQuery.cs b/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQuery.cs index f14bfbf..aec8067 100644 --- a/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQuery.cs +++ b/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQuery.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Users.Queries.GetAllUsers; diff --git a/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQueryHandler.cs b/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQueryHandler.cs index cbfdb05..2a7292e 100644 --- a/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQueryHandler.cs +++ b/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersQueryHandler.cs @@ -4,6 +4,11 @@ using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Application.Features.Users.Queries.Dtos; using Microsoft.EntityFrameworkCore; +using CellularManagement.Domain.Common; +using System.Threading.Tasks; +using System.Threading; +using System.Linq; +using System; namespace CellularManagement.Application.Features.Users.Queries.GetAllUsers; diff --git a/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersResponse.cs b/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersResponse.cs index 17d5a8e..405d3fa 100644 --- a/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersResponse.cs +++ b/src/CellularManagement.Application/Features/Users/Queries/GetAllUsers/GetAllUsersResponse.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections.Generic; using CellularManagement.Application.Features.Users.Queries.Dtos; namespace CellularManagement.Application.Features.Users.Queries.GetAllUsers; diff --git a/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQuery.cs b/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQuery.cs index ecd550d..f84797f 100644 --- a/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQuery.cs +++ b/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQuery.cs @@ -1,3 +1,4 @@ +using CellularManagement.Domain.Common; using MediatR; namespace CellularManagement.Application.Features.Users.Queries.GetUserById; diff --git a/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQueryHandler.cs b/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQueryHandler.cs index 086ae34..963c84e 100644 --- a/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQueryHandler.cs +++ b/src/CellularManagement.Application/Features/Users/Queries/GetUserById/GetUserByIdQueryHandler.cs @@ -3,6 +3,10 @@ using Microsoft.Extensions.Logging; using MediatR; using CellularManagement.Domain.Entities; using CellularManagement.Application.Features.Users.Queries.Dtos; +using CellularManagement.Domain.Common; +using System.Threading; +using System.Threading.Tasks; +using System; namespace CellularManagement.Application.Features.Users.Queries.GetUserById; diff --git a/src/CellularManagement.Application/Common/OperationResult.cs b/src/CellularManagement.Domain/Common/OperationResult.cs similarity index 95% rename from src/CellularManagement.Application/Common/OperationResult.cs rename to src/CellularManagement.Domain/Common/OperationResult.cs index 14ca0ed..42af19c 100644 --- a/src/CellularManagement.Application/Common/OperationResult.cs +++ b/src/CellularManagement.Domain/Common/OperationResult.cs @@ -1,3 +1,8 @@ +using System.Collections.Generic; +using System.Linq; + +namespace CellularManagement.Domain.Common; + /// /// 泛型结果类,用于封装操作结果 /// @@ -73,4 +78,4 @@ public sealed record OperationResult( { return new OperationResult(null, errorMessages, default); } -} +} \ No newline at end of file diff --git a/src/CellularManagement.Application/Services/ICacheService.cs b/src/CellularManagement.Domain/Services/ICacheService.cs similarity index 94% rename from src/CellularManagement.Application/Services/ICacheService.cs rename to src/CellularManagement.Domain/Services/ICacheService.cs index 2f46d71..0c2a19a 100644 --- a/src/CellularManagement.Application/Services/ICacheService.cs +++ b/src/CellularManagement.Domain/Services/ICacheService.cs @@ -1,9 +1,10 @@ using Microsoft.Extensions.Caching.Memory; -namespace CellularManagement.Application.Services; +namespace CellularManagement.Domain.Services; /// /// 缓存服务接口 +/// 定义缓存操作的核心业务逻辑 /// public interface ICacheService { diff --git a/src/CellularManagement.Domain/Services/IEmailService.cs b/src/CellularManagement.Domain/Services/IEmailService.cs new file mode 100644 index 0000000..4913292 --- /dev/null +++ b/src/CellularManagement.Domain/Services/IEmailService.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; + +namespace CellularManagement.Domain.Services; + +/// +/// 邮箱服务接口 +/// 定义发送邮件和验证邮箱的基本功能 +/// +public interface IEmailService +{ + /// + /// 发送验证码邮件 + /// + /// 收件人邮箱 + /// 验证码 + /// 发送结果 + Task SendVerificationCodeAsync(string to, string verificationCode); + + /// + /// 发送注册成功邮件 + /// + /// 收件人邮箱 + /// 用户名 + /// 发送结果 + Task SendRegistrationSuccessAsync(string to, string username); + + /// + /// 验证邮箱格式 + /// + /// 邮箱地址 + /// 验证结果 + bool ValidateEmail(string email); +} \ No newline at end of file diff --git a/src/CellularManagement.Domain/Services/IEmailVerificationService.cs b/src/CellularManagement.Domain/Services/IEmailVerificationService.cs new file mode 100644 index 0000000..f44fac6 --- /dev/null +++ b/src/CellularManagement.Domain/Services/IEmailVerificationService.cs @@ -0,0 +1,25 @@ +using System.Threading.Tasks; + +namespace CellularManagement.Domain.Services; + +/// +/// 邮箱验证码服务接口 +/// 定义验证码生成、发送和验证的核心业务逻辑 +/// +public interface IEmailVerificationService +{ + /// + /// 生成并发送验证码 + /// + /// 邮箱地址 + /// 是否发送成功 + Task GenerateAndSendVerificationCodeAsync(string email); + + /// + /// 验证验证码 + /// + /// 邮箱地址 + /// 验证码 + /// 验证结果 + Task VerifyCodeAsync(string email, string code); +} \ No newline at end of file diff --git a/src/CellularManagement.Application/Services/IJwtProvider.cs b/src/CellularManagement.Domain/Services/IJwtProvider.cs similarity index 97% rename from src/CellularManagement.Application/Services/IJwtProvider.cs rename to src/CellularManagement.Domain/Services/IJwtProvider.cs index 9bb9b9d..60f3c19 100644 --- a/src/CellularManagement.Application/Services/IJwtProvider.cs +++ b/src/CellularManagement.Domain/Services/IJwtProvider.cs @@ -1,6 +1,7 @@ +using System.Collections.Generic; using System.Security.Claims; -namespace CellularManagement.Application.Services; +namespace CellularManagement.Domain.Services; /// /// JWT 令牌提供者接口 diff --git a/src/CellularManagement.Application/Services/IKeyRotationService.cs b/src/CellularManagement.Domain/Services/IKeyRotationService.cs similarity index 86% rename from src/CellularManagement.Application/Services/IKeyRotationService.cs rename to src/CellularManagement.Domain/Services/IKeyRotationService.cs index 02ea113..942e02c 100644 --- a/src/CellularManagement.Application/Services/IKeyRotationService.cs +++ b/src/CellularManagement.Domain/Services/IKeyRotationService.cs @@ -1,9 +1,10 @@ using System.Threading.Tasks; -namespace CellularManagement.Application.Services; +namespace CellularManagement.Domain.Services; /// /// 密钥轮换服务接口 +/// 定义密钥轮换的核心业务逻辑 /// public interface IKeyRotationService { diff --git a/src/CellularManagement.Infrastructure/DependencyInjection.cs b/src/CellularManagement.Infrastructure/DependencyInjection.cs index f9e1ec5..c289890 100644 --- a/src/CellularManagement.Infrastructure/DependencyInjection.cs +++ b/src/CellularManagement.Infrastructure/DependencyInjection.cs @@ -6,13 +6,13 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; -using CellularManagement.Application.Services; using CellularManagement.Infrastructure.Services; using Scrutor; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using CellularManagement.Infrastructure.Configurations; +using CellularManagement.Domain.Services; namespace CellularManagement.Infrastructure; @@ -49,6 +49,11 @@ public static class DependencyInjection // 添加 JWT 服务 services.AddJwtServices(configuration); + // 添加邮箱服务 + services.Configure(configuration.GetSection(EmailOptions.SectionName)); + services.AddScoped(); + services.AddScoped(); + // 配置数据库选项 services.Configure(configuration.GetSection(DatabaseOptions.SectionName)); var databaseOptionsConfig = configuration.GetSection(DatabaseOptions.SectionName).Get(); diff --git a/src/CellularManagement.Infrastructure/Options/EmailOptions.cs b/src/CellularManagement.Infrastructure/Options/EmailOptions.cs new file mode 100644 index 0000000..566c429 --- /dev/null +++ b/src/CellularManagement.Infrastructure/Options/EmailOptions.cs @@ -0,0 +1,42 @@ +namespace CellularManagement.Infrastructure.Options; + +/// +/// 邮箱配置选项 +/// +public class EmailOptions +{ + /// + /// 配置节点名称 + /// + public const string SectionName = "Email"; + + /// + /// SMTP服务器地址 + /// + public string SmtpServer { get; set; } = string.Empty; + + /// + /// SMTP服务器端口 + /// + public int SmtpPort { get; set; } + + /// + /// 发件人邮箱地址 + /// + public string FromEmail { get; set; } = string.Empty; + + /// + /// 发件人显示名称 + /// + public string FromName { get; set; } = string.Empty; + + /// + /// 邮箱密码或授权码 + /// + public string Password { get; set; } = string.Empty; + + /// + /// 是否启用SSL + /// + public bool EnableSsl { get; set; } +} \ No newline at end of file diff --git a/src/CellularManagement.Infrastructure/Services/CacheService.cs b/src/CellularManagement.Infrastructure/Services/CacheService.cs index 28c8d55..0fa6eab 100644 --- a/src/CellularManagement.Infrastructure/Services/CacheService.cs +++ b/src/CellularManagement.Infrastructure/Services/CacheService.cs @@ -1,4 +1,5 @@ -using CellularManagement.Application.Services; + +using CellularManagement.Domain.Services; using Microsoft.Extensions.Caching.Memory; namespace CellularManagement.Infrastructure.Services; diff --git a/src/CellularManagement.Infrastructure/Services/EmailService.cs b/src/CellularManagement.Infrastructure/Services/EmailService.cs new file mode 100644 index 0000000..602af04 --- /dev/null +++ b/src/CellularManagement.Infrastructure/Services/EmailService.cs @@ -0,0 +1,116 @@ +using System; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using CellularManagement.Domain.Services; +using CellularManagement.Infrastructure.Options; +using MailKit.Net.Smtp; +using MailKit.Security; +using Microsoft.Extensions.Options; +using MimeKit; + +namespace CellularManagement.Infrastructure.Services; + +/// +/// 邮箱服务实现类 +/// +public class EmailService : IEmailService +{ + private readonly EmailOptions _emailOptions; + + /// + /// 构造函数 + /// + /// 邮箱配置选项 + public EmailService(IOptions emailOptions) + { + _emailOptions = emailOptions.Value; + } + + /// + /// 发送验证码邮件 + /// + public async Task SendVerificationCodeAsync(string to, string verificationCode) + { + try + { + var message = new MimeMessage(); + message.From.Add(new MailboxAddress(_emailOptions.FromName, _emailOptions.FromEmail)); + message.To.Add(new MailboxAddress("", to)); + message.Subject = "邮箱验证码"; + + var bodyBuilder = new BodyBuilder + { + HtmlBody = $@" +

您的验证码

+

您的验证码是:{verificationCode}

+

验证码有效期为5分钟,请尽快使用。

+

如果这不是您的操作,请忽略此邮件。

" + }; + + message.Body = bodyBuilder.ToMessageBody(); + + using var client = new SmtpClient(); + await client.ConnectAsync(_emailOptions.SmtpServer, _emailOptions.SmtpPort, _emailOptions.EnableSsl ? SecureSocketOptions.SslOnConnect : SecureSocketOptions.StartTls); + await client.AuthenticateAsync(_emailOptions.FromEmail, _emailOptions.Password); + await client.SendAsync(message); + await client.DisconnectAsync(true); + + return true; + } + catch (Exception) + { + return false; + } + } + + /// + /// 发送注册成功邮件 + /// + public async Task SendRegistrationSuccessAsync(string to, string username) + { + try + { + var message = new MimeMessage(); + message.From.Add(new MailboxAddress(_emailOptions.FromName, _emailOptions.FromEmail)); + message.To.Add(new MailboxAddress(username, to)); + message.Subject = "注册成功通知"; + + var bodyBuilder = new BodyBuilder + { + HtmlBody = $@" +

注册成功

+

尊敬的 {username}:

+

恭喜您成功注册我们的服务!

+

您现在可以使用注册的邮箱和密码登录系统。

+

如有任何问题,请随时联系我们。

" + }; + + message.Body = bodyBuilder.ToMessageBody(); + + using var client = new SmtpClient(); + await client.ConnectAsync(_emailOptions.SmtpServer, _emailOptions.SmtpPort, _emailOptions.EnableSsl ? SecureSocketOptions.SslOnConnect : SecureSocketOptions.StartTls); + await client.AuthenticateAsync(_emailOptions.FromEmail, _emailOptions.Password); + await client.SendAsync(message); + await client.DisconnectAsync(true); + + return true; + } + catch (Exception) + { + return false; + } + } + + /// + /// 验证邮箱格式 + /// + public bool ValidateEmail(string email) + { + if (string.IsNullOrWhiteSpace(email)) + return false; + + // 使用正则表达式验证邮箱格式 + const string pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"; + return Regex.IsMatch(email, pattern); + } +} \ No newline at end of file diff --git a/src/CellularManagement.Infrastructure/Services/EmailVerificationService.cs b/src/CellularManagement.Infrastructure/Services/EmailVerificationService.cs new file mode 100644 index 0000000..255d399 --- /dev/null +++ b/src/CellularManagement.Infrastructure/Services/EmailVerificationService.cs @@ -0,0 +1,132 @@ +using System; +using System.Threading.Tasks; +using CellularManagement.Domain.Services; +using Microsoft.Extensions.Caching.Distributed; +using System.Text.Json; + +namespace CellularManagement.Infrastructure.Services; + +/// +/// 邮箱验证码服务 +/// 提供验证码生成、发送和验证的具体实现 +/// +public class EmailVerificationService : IEmailVerificationService +{ + private readonly IEmailService _emailService; + private readonly IDistributedCache _cache; + private const string CacheKeyPrefix = "EmailVerification_"; + private const int VerificationCodeLength = 6; + private const int VerificationCodeExpirationMinutes = 5; + + /// + /// 构造函数 + /// + /// 邮箱服务 + /// 分布式缓存 + public EmailVerificationService(IEmailService emailService, IDistributedCache cache) + { + _emailService = emailService; + _cache = cache; + } + + /// + /// 生成并发送验证码 + /// + /// 邮箱地址 + /// 是否发送成功 + public async Task GenerateAndSendVerificationCodeAsync(string email) + { + if (!_emailService.ValidateEmail(email)) + { + return false; + } + + // 生成6位数字验证码 + var verificationCode = GenerateVerificationCode(); + + // 将验证码保存到缓存 + var cacheKey = $"{CacheKeyPrefix}{email}"; + var cacheValue = JsonSerializer.Serialize(new + { + Code = verificationCode, + CreatedAt = DateTime.UtcNow + }); + + await _cache.SetStringAsync( + cacheKey, + cacheValue, + new DistributedCacheEntryOptions + { + AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(VerificationCodeExpirationMinutes) + }); + + // 发送验证码邮件 + return await _emailService.SendVerificationCodeAsync(email, verificationCode); + } + + /// + /// 验证验证码 + /// + /// 邮箱地址 + /// 验证码 + /// 验证结果 + public async Task VerifyCodeAsync(string email, string code) + { + var cacheKey = $"{CacheKeyPrefix}{email}"; + var cachedValue = await _cache.GetStringAsync(cacheKey); + + if (string.IsNullOrEmpty(cachedValue)) + { + return false; + } + + var verificationData = JsonSerializer.Deserialize(cachedValue); + + if (verificationData == null) + { + return false; + } + + // 验证码是否过期 + if (DateTime.UtcNow - verificationData.CreatedAt > TimeSpan.FromMinutes(VerificationCodeExpirationMinutes)) + { + await _cache.RemoveAsync(cacheKey); + return false; + } + + // 验证码是否匹配 + if (verificationData.Code != code) + { + return false; + } + + // 验证成功后删除缓存 + await _cache.RemoveAsync(cacheKey); + return true; + } + + /// + /// 生成验证码 + /// + private string GenerateVerificationCode() + { + var random = new Random(); + var code = string.Empty; + + for (int i = 0; i < VerificationCodeLength; i++) + { + code += random.Next(0, 10).ToString(); + } + + return code; + } + + /// + /// 验证数据 + /// + private class VerificationData + { + public string Code { get; set; } = string.Empty; + public DateTime CreatedAt { get; set; } + } +} \ No newline at end of file diff --git a/src/CellularManagement.Infrastructure/Services/JwtProvider.cs b/src/CellularManagement.Infrastructure/Services/JwtProvider.cs index 68a7ee9..d8f7727 100644 --- a/src/CellularManagement.Infrastructure/Services/JwtProvider.cs +++ b/src/CellularManagement.Infrastructure/Services/JwtProvider.cs @@ -1,13 +1,13 @@ using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; -using CellularManagement.Application.Services; using CellularManagement.Infrastructure.Options; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Caching.Memory; using System.Text.Json; +using CellularManagement.Domain.Services; namespace CellularManagement.Infrastructure.Services; diff --git a/src/CellularManagement.Infrastructure/Services/KeyRotationBackgroundService.cs b/src/CellularManagement.Infrastructure/Services/KeyRotationBackgroundService.cs index 5e2d8ef..6d00c22 100644 --- a/src/CellularManagement.Infrastructure/Services/KeyRotationBackgroundService.cs +++ b/src/CellularManagement.Infrastructure/Services/KeyRotationBackgroundService.cs @@ -1,7 +1,7 @@ using System; using System.Threading; using System.Threading.Tasks; -using CellularManagement.Application.Services; +using CellularManagement.Domain.Services; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; diff --git a/src/CellularManagement.Infrastructure/Services/KeyRotationService.cs b/src/CellularManagement.Infrastructure/Services/KeyRotationService.cs index aed5ca2..11a639d 100644 --- a/src/CellularManagement.Infrastructure/Services/KeyRotationService.cs +++ b/src/CellularManagement.Infrastructure/Services/KeyRotationService.cs @@ -2,10 +2,10 @@ using System; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using CellularManagement.Application.Services; using CellularManagement.Infrastructure.Options; using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; +using CellularManagement.Domain.Services; namespace CellularManagement.Infrastructure.Services; diff --git a/src/CellularManagement.Presentation/Controllers/AuthController.cs b/src/CellularManagement.Presentation/Controllers/AuthController.cs index 9444955..838a90d 100644 --- a/src/CellularManagement.Presentation/Controllers/AuthController.cs +++ b/src/CellularManagement.Presentation/Controllers/AuthController.cs @@ -5,7 +5,7 @@ using CellularManagement.Application.Features.Auth.Commands.RegisterUser; using CellularManagement.Application.Features.Auth.Commands.RefreshToken; using CellularManagement.Application.Common; using Microsoft.Extensions.Logging; -using CellularManagement.Application.Services; +using CellularManagement.Domain.Services; using Microsoft.Extensions.Caching.Memory; using CellularManagement.Infrastructure.Configurations; using Microsoft.Extensions.Options; @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Http; using CellularManagement.Presentation.Abstractions; using CellularManagement.Application.Features.Auth.Commands.Login; using Swashbuckle.AspNetCore.Filters; +using CellularManagement.Domain.Common; namespace CellularManagement.Presentation.Controllers; diff --git a/src/CellularManagement.Presentation/Controllers/PermissionsController.cs b/src/CellularManagement.Presentation/Controllers/PermissionsController.cs index 0363bae..84ef99a 100644 --- a/src/CellularManagement.Presentation/Controllers/PermissionsController.cs +++ b/src/CellularManagement.Presentation/Controllers/PermissionsController.cs @@ -6,6 +6,7 @@ using CellularManagement.Application.Common; using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Http; using CellularManagement.Presentation.Abstractions; +using CellularManagement.Domain.Common; namespace CellularManagement.Presentation.Controllers; diff --git a/src/CellularManagement.Presentation/Controllers/RolePermissionController.cs b/src/CellularManagement.Presentation/Controllers/RolePermissionController.cs index e0ab9c1..71afc5a 100644 --- a/src/CellularManagement.Presentation/Controllers/RolePermissionController.cs +++ b/src/CellularManagement.Presentation/Controllers/RolePermissionController.cs @@ -7,6 +7,7 @@ using CellularManagement.Application.Features.RolePermissions.Queries.GetRolePer using CellularManagement.Application.Common; using Microsoft.AspNetCore.Http; using CellularManagement.Presentation.Abstractions; +using CellularManagement.Domain.Common; namespace CellularManagement.Presentation.Controllers; diff --git a/src/CellularManagement.Presentation/Controllers/RolesController.cs b/src/CellularManagement.Presentation/Controllers/RolesController.cs index 90a4cdf..bb90d3f 100644 --- a/src/CellularManagement.Presentation/Controllers/RolesController.cs +++ b/src/CellularManagement.Presentation/Controllers/RolesController.cs @@ -9,6 +9,7 @@ using CellularManagement.Application.Common; using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Http; using CellularManagement.Presentation.Abstractions; +using CellularManagement.Domain.Common; namespace CellularManagement.Presentation.Controllers; diff --git a/src/CellularManagement.Presentation/Controllers/UsersController.cs b/src/CellularManagement.Presentation/Controllers/UsersController.cs index ac20f2b..6804895 100644 --- a/src/CellularManagement.Presentation/Controllers/UsersController.cs +++ b/src/CellularManagement.Presentation/Controllers/UsersController.cs @@ -8,9 +8,10 @@ using CellularManagement.Application.Features.Users.Queries.GetAllUsers; using CellularManagement.Presentation.Abstractions; using CellularManagement.Application.Common; using Microsoft.Extensions.Logging; -using CellularManagement.Application.Services; +using CellularManagement.Domain.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Authorization; +using CellularManagement.Domain.Common; namespace CellularManagement.Presentation.Controllers; diff --git a/src/CellularManagement.Presentation/appsettings.json b/src/CellularManagement.Presentation/appsettings.json new file mode 100644 index 0000000..b583c03 --- /dev/null +++ b/src/CellularManagement.Presentation/appsettings.json @@ -0,0 +1,17 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "Email": { + "SmtpServer": "smtp.example.com", + "SmtpPort": 587, + "FromEmail": "noreply@example.com", + "FromName": "系统通知", + "Password": "your-email-password", + "EnableSsl": true + } +} \ No newline at end of file