feat: 基础模块

注册登录
用户管理
角色管理
部门管理
消息管理
接口管理
菜单管理
字典管理
缓存管理
请求日志
系统设置
版本信息
代码生成
This commit is contained in:
tk
2023-11-17 18:54:31 +08:00
parent 18b4d7547a
commit d26e4c77cc
755 changed files with 30416 additions and 42743 deletions

View File

@@ -12,14 +12,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 接口服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class ApiController : ControllerBase<IApiCache, IApiService>, IApiModule
public sealed class ApiController(IApiCache cache) : ControllerBase<IApiCache, IApiService>(cache), IApiModule
{
/// <summary>
/// Initializes a new instance of the <see cref="ApiController" /> class.
/// </summary>
public ApiController(IApiCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除接口
/// </summary>

View File

@@ -11,14 +11,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 缓存服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class CacheController : ControllerBase<ICacheCache, ICacheService>, ICacheModule
public sealed class CacheController(ICacheCache cache) : ControllerBase<ICacheCache, ICacheService>(cache), ICacheModule
{
/// <summary>
/// Initializes a new instance of the <see cref="CacheController" /> class.
/// </summary>
public CacheController(ICacheCache cache) //
: base(cache) { }
/// <summary>
/// 缓存统计
/// </summary>
@@ -30,8 +24,8 @@ public sealed class CacheController : ControllerBase<ICacheCache, ICacheService>
/// <summary>
/// 获取所有缓存项
/// </summary>
public PagedQueryRsp<GetAllEntriesRsp> GetAllEntries(PagedQueryReq<GetAllEntriesReq> req)
public Task<PagedQueryRsp<GetAllEntriesRsp>> GetAllEntriesAsync(PagedQueryReq<GetAllEntriesReq> req)
{
return Cache.GetAllEntries(req);
return Cache.GetAllEntriesAsync(req);
}
}

View File

@@ -10,14 +10,9 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 人机验证服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class CaptchaController : ControllerBase<ICaptchaCache, ICaptchaService>, ICaptchaModule
public sealed class CaptchaController(ICaptchaCache cache) : ControllerBase<ICaptchaCache, ICaptchaService>(cache)
, ICaptchaModule
{
/// <summary>
/// Initializes a new instance of the <see cref="CaptchaController" /> class.
/// </summary>
public CaptchaController(ICaptchaCache cache) //
: base(cache) { }
/// <summary>
/// 获取人机校验图
/// </summary>

View File

@@ -12,14 +12,9 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 配置服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class ConfigController : ControllerBase<IConfigCache, IConfigService>, IConfigModule
public sealed class ConfigController(IConfigCache cache) : ControllerBase<IConfigCache, IConfigService>(cache)
, IConfigModule
{
/// <summary>
/// Initializes a new instance of the <see cref="ConfigController" /> class.
/// </summary>
public ConfigController(IConfigCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除配置
/// </summary>
@@ -59,7 +54,6 @@ public sealed class ConfigController : ControllerBase<IConfigCache, IConfigServi
/// <summary>
/// 获取单个配置
/// </summary>
[NonAction]
public Task<QueryConfigRsp> GetAsync(QueryConfigReq req)
{
return Cache.GetAsync(req);

View File

@@ -11,19 +11,10 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// </summary>
[AllowAnonymous]
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class ConstantController : ControllerBase<IConstantCache, IConstantService>, IConstantModule
public sealed class ConstantController
(IConstantCache cache, IOptions<JsonOptions> jsonOptions) : ControllerBase<IConstantCache, IConstantService>(cache)
, IConstantModule
{
private readonly JsonOptions _jsonOptions;
/// <summary>
/// Initializes a new instance of the <see cref="ConstantController" /> class.
/// </summary>
public ConstantController(IConstantCache cache, IOptions<JsonOptions> jsonOptions) //
: base(cache)
{
_jsonOptions = jsonOptions.Value;
}
/// <summary>
/// 获得常量字符串
/// </summary>
@@ -78,10 +69,10 @@ public sealed class ConstantController : ControllerBase<IConstantCache, IConstan
return Cache.GetNumbersDic();
}
private IActionResult OriginNamingResult<T>(T data)
private JsonResult OriginNamingResult<T>(T data)
{
return new JsonResult( //
new RestfulInfo<T> { Code = 0, Data = data }
, new JsonSerializerOptions(_jsonOptions.JsonSerializerOptions) { DictionaryKeyPolicy = null });
new RestfulInfo<T> { Code = 0, Data = data }
, new JsonSerializerOptions(jsonOptions.Value.JsonSerializerOptions) { DictionaryKeyPolicy = null });
}
}

View File

@@ -12,14 +12,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 部门服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class DeptController : ControllerBase<IDeptCache, IDeptService>, IDeptModule
public sealed class DeptController(IDeptCache cache) : ControllerBase<IDeptCache, IDeptService>(cache), IDeptModule
{
/// <summary>
/// Initializes a new instance of the <see cref="DeptController" /> class.
/// </summary>
public DeptController(IDeptCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除部门
/// </summary>
@@ -59,7 +53,6 @@ public sealed class DeptController : ControllerBase<IDeptCache, IDeptService>, I
/// <summary>
/// 获取单个部门
/// </summary>
[NonAction]
public Task<QueryDeptRsp> GetAsync(QueryDeptReq req)
{
return Cache.GetAsync(req);

View File

@@ -10,14 +10,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 开发服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class DevController : ControllerBase<IDevCache, IDevService>, IDevModule
public sealed class DevController(IDevCache cache) : ControllerBase<IDevCache, IDevService>(cache), IDevModule
{
/// <summary>
/// Initializes a new instance of the <see cref="DevController" /> class.
/// </summary>
public DevController(IDevCache cache) //
: base(cache) { }
/// <summary>
/// 生成后端代码
/// </summary>

View File

@@ -13,14 +13,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 字典服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class DicController : ControllerBase<IDicCache, IDicService>, IDicModule
public sealed class DicController(IDicCache cache) : ControllerBase<IDicCache, IDicService>(cache), IDicModule
{
/// <summary>
/// Initializes a new instance of the <see cref="DicController" /> class.
/// </summary>
public DicController(IDicCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除字典目录
/// </summary>
@@ -75,6 +69,22 @@ public sealed class DicController : ControllerBase<IDicCache, IDicService>, IDic
return Cache.DeleteContentAsync(req);
}
/// <summary>
/// 获取单个字典目录
/// </summary>
public Task<QueryDicCatalogRsp> GetCatalogAsync(QueryDicCatalogReq req)
{
return Cache.GetCatalogAsync(req);
}
/// <summary>
/// 获取单个字典内容
/// </summary>
public Task<QueryDicContentRsp> GetContentAsync(QueryDicContentReq req)
{
return Cache.GetContentAsync(req);
}
/// <summary>
/// 分页查询字典目录
/// </summary>

View File

@@ -9,14 +9,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 文件服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class FileController : ControllerBase<IFileCache, IFileService>, IFileModule
public sealed class FileController(IFileCache cache) : ControllerBase<IFileCache, IFileService>(cache), IFileModule
{
/// <summary>
/// Initializes a new instance of the <see cref="FileController" /> class.
/// </summary>
public FileController(IFileCache cache) //
: base(cache) { }
/// <summary>
/// 文件上传
/// </summary>

View File

@@ -12,14 +12,9 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 请求日志服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class LogController : ControllerBase<IRequestLogCache, IRequestLogService>, IRequestLogModule
public sealed class LogController(IRequestLogCache cache) : ControllerBase<IRequestLogCache, IRequestLogService>(cache)
, IRequestLogModule
{
/// <summary>
/// Initializes a new instance of the <see cref="LogController" /> class.
/// </summary>
public LogController(IRequestLogCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除请求日志
/// </summary>
@@ -62,7 +57,6 @@ public sealed class LogController : ControllerBase<IRequestLogCache, IRequestLog
/// <summary>
/// 获取单个请求日志
/// </summary>
[NonAction]
public Task<QueryRequestLogRsp> GetAsync(QueryRequestLogReq req)
{
return Cache.GetAsync(req);

View File

@@ -12,14 +12,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 菜单服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class MenuController : ControllerBase<IMenuCache, IMenuService>, IMenuModule
public sealed class MenuController(IMenuCache cache) : ControllerBase<IMenuCache, IMenuService>(cache), IMenuModule
{
/// <summary>
/// Initializes a new instance of the <see cref="MenuController" /> class.
/// </summary>
public MenuController(IMenuCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除菜单
/// </summary>
@@ -59,7 +53,6 @@ public sealed class MenuController : ControllerBase<IMenuCache, IMenuService>, I
/// <summary>
/// 获取单个菜单
/// </summary>
[NonAction]
public Task<QueryMenuRsp> GetAsync(QueryMenuReq req)
{
return Cache.GetAsync(req);

View File

@@ -12,14 +12,8 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 角色服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class RoleController : ControllerBase<IRoleCache, IRoleService>, IRoleModule
public sealed class RoleController(IRoleCache cache) : ControllerBase<IRoleCache, IRoleService>(cache), IRoleModule
{
/// <summary>
/// Initializes a new instance of the <see cref="RoleController" /> class.
/// </summary>
public RoleController(IRoleCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除角色
/// </summary>
@@ -59,7 +53,6 @@ public sealed class RoleController : ControllerBase<IRoleCache, IRoleService>, I
/// <summary>
/// 获取单个角色
/// </summary>
[NonAction]
public Task<QueryRoleRsp> GetAsync(QueryRoleReq req)
{
return Cache.GetAsync(req);

View File

@@ -0,0 +1,118 @@
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.SiteMsg;
using NetAdmin.Domain.Dto.Sys.SiteMsgFlag;
using NetAdmin.Host.Attributes;
using NetAdmin.Host.Controllers;
using NetAdmin.SysComponent.Application.Modules.Sys;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
using NetAdmin.SysComponent.Cache.Sys.Dependency;
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// <summary>
/// 站内信服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class SiteMsgController(ISiteMsgCache cache) : ControllerBase<ISiteMsgCache, ISiteMsgService>(cache)
, ISiteMsgModule
{
/// <summary>
/// 批量删除站内信
/// </summary>
[Transaction]
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
{
return Cache.BulkDeleteAsync(req);
}
/// <summary>
/// 创建站内信
/// </summary>
[Transaction]
public Task<QuerySiteMsgRsp> CreateAsync(CreateSiteMsgReq req)
{
return Cache.CreateAsync(req);
}
/// <summary>
/// 删除站内信
/// </summary>
[Transaction]
public Task<int> DeleteAsync(DelReq req)
{
return Cache.DeleteAsync(req);
}
/// <summary>
/// 站内信是否存在
/// </summary>
public Task<bool> ExistAsync(QueryReq<QuerySiteMsgReq> req)
{
return Cache.ExistAsync(req);
}
/// <summary>
/// 获取单个站内信
/// </summary>
public Task<QuerySiteMsgRsp> GetAsync(QuerySiteMsgReq req)
{
return Cache.GetAsync(req);
}
/// <summary>
/// 获取单个我的站内信
/// </summary>
public Task<QuerySiteMsgRsp> GetMineAsync(QuerySiteMsgReq req)
{
return Cache.GetMineAsync(req);
}
/// <summary>
/// 分页查询站内信
/// </summary>
public Task<PagedQueryRsp<QuerySiteMsgRsp>> PagedQueryAsync(PagedQueryReq<QuerySiteMsgReq> req)
{
return Cache.PagedQueryAsync(req);
}
/// <summary>
/// 分页查询我的站内信
/// </summary>
public Task<PagedQueryRsp<QuerySiteMsgRsp>> PagedQueryMineAsync(PagedQueryReq<QuerySiteMsgReq> req)
{
return Cache.PagedQueryMineAsync(req);
}
/// <summary>
/// 查询站内信
/// </summary>
public Task<IEnumerable<QuerySiteMsgRsp>> QueryAsync(QueryReq<QuerySiteMsgReq> req)
{
return Cache.QueryAsync(req);
}
/// <summary>
/// 设置站内信状态
/// </summary>
public Task SetSiteMsgStatusAsync(UpdateSiteMsgFlagReq req)
{
return Cache.SetSiteMsgStatusAsync(req);
}
/// <summary>
/// 未读数量
/// </summary>
public Task<long> UnreadCountAsync()
{
return Cache.UnreadCountAsync();
}
/// <summary>
/// 更新站内信
/// </summary>
[Transaction]
public Task<QuerySiteMsgRsp> UpdateAsync(UpdateSiteMsgReq req)
{
return Cache.UpdateAsync(req);
}
}

View File

@@ -1,3 +1,4 @@
using NetAdmin.Domain.Dto.Sys.Tool;
using NetAdmin.Host.Controllers;
using NetAdmin.SysComponent.Application.Modules.Sys;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
@@ -9,29 +10,32 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 工具服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class ToolsController : ControllerBase<IToolsCache, IToolsService>, IToolsModule
public sealed class ToolsController(IToolsCache cache) : ControllerBase<IToolsCache, IToolsService>(cache), IToolsModule
{
/// <summary>
/// Initializes a new instance of the <see cref="ToolsController" /> class.
/// </summary>
public ToolsController(IToolsCache cache) //
: base(cache) { }
/// <summary>
/// 服务器时间
/// 获取模块信息
/// </summary>
[AllowAnonymous]
public DateTime GetServerUtcTime()
public Task<IEnumerable<GetModulesRsp>> GetModulesAsync()
{
return Cache.GetServerUtcTime();
return Cache.GetModulesAsync();
}
/// <summary>
/// 版本信息
/// 获取服务器时间
/// </summary>
[AllowAnonymous]
public string Version()
public Task<DateTime> GetServerUtcTimeAsync()
{
return Cache.Version();
return Cache.GetServerUtcTimeAsync();
}
/// <summary>
/// 获取版本信息
/// </summary>
[AllowAnonymous]
public Task<string> GetVersionAsync()
{
return Cache.GetVersionAsync();
}
}

View File

@@ -13,19 +13,9 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 用户服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class UserController : ControllerBase<IUserCache, IUserService>, IUserModule
public sealed class UserController
(IUserCache cache, IConfigCache configCache) : ControllerBase<IUserCache, IUserService>(cache), IUserModule
{
private readonly IConfigCache _configCache;
/// <summary>
/// Initializes a new instance of the <see cref="UserController" /> class.
/// </summary>
public UserController(IUserCache cache, IConfigCache configCache) //
: base(cache)
{
_configCache = configCache;
}
/// <summary>
/// 批量删除用户
/// </summary>
@@ -84,7 +74,6 @@ public sealed class UserController : ControllerBase<IUserCache, IUserService>, I
/// <summary>
/// 获取单个用户
/// </summary>
[NonAction]
public Task<QueryUserRsp> GetAsync(QueryUserReq req)
{
return Cache.GetAsync(req);
@@ -145,7 +134,7 @@ public sealed class UserController : ControllerBase<IUserCache, IUserService>, I
[AllowAnonymous]
public async Task<UserInfoRsp> RegisterAsync(RegisterUserReq req)
{
var config = await _configCache.GetLatestConfigAsync();
var config = await configCache.GetLatestConfigAsync();
return await Cache.RegisterAsync(req with {
DeptId = config.UserRegisterDeptId

View File

@@ -12,66 +12,57 @@ namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// 验证码服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
public sealed class VerifyCodeController : ControllerBase<IVerifyCodeCache, IVerifyCodeService>, IVerifyCodeModule
public sealed class VerifyCodeController
(IVerifyCodeCache cache, ICaptchaCache captchaCache) : ControllerBase<IVerifyCodeCache, IVerifyCodeService>(cache)
, IVerifyCodeModule
{
private readonly ICaptchaCache _captchaCache;
/// <summary>
/// Initializes a new instance of the <see cref="VerifyCodeController" /> class.
/// </summary>
public VerifyCodeController(IVerifyCodeCache cache, ICaptchaCache captchaCache) //
: base(cache)
{
_captchaCache = captchaCache;
}
/// <inheritdoc />
[NonAction]
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
{
throw new NotImplementedException();
return Cache.BulkDeleteAsync(req);
}
/// <inheritdoc />
[NonAction]
public Task<QueryVerifyCodeRsp> CreateAsync(CreateVerifyCodeReq req)
{
throw new NotImplementedException();
return Cache.CreateAsync(req);
}
/// <inheritdoc />
[NonAction]
public Task<int> DeleteAsync(DelReq req)
{
throw new NotImplementedException();
return Cache.DeleteAsync(req);
}
/// <inheritdoc />
[NonAction]
public Task<bool> ExistAsync(QueryReq<QueryVerifyCodeReq> req)
{
throw new NotImplementedException();
return Cache.ExistAsync(req);
}
/// <inheritdoc />
[NonAction]
public Task<QueryVerifyCodeRsp> GetAsync(QueryVerifyCodeReq req)
{
throw new NotImplementedException();
return Cache.GetAsync(req);
}
/// <inheritdoc />
[NonAction]
public Task<PagedQueryRsp<QueryVerifyCodeRsp>> PagedQueryAsync(PagedQueryReq<QueryVerifyCodeReq> req)
{
throw new NotImplementedException();
return Cache.PagedQueryAsync(req);
}
/// <inheritdoc />
[NonAction]
public Task<IEnumerable<QueryVerifyCodeRsp>> QueryAsync(QueryReq<QueryVerifyCodeReq> req)
{
throw new NotImplementedException();
return Cache.QueryAsync(req);
}
/// <summary>
@@ -81,7 +72,7 @@ public sealed class VerifyCodeController : ControllerBase<IVerifyCodeCache, IVer
[AllowAnonymous]
public async Task<SendVerifyCodeRsp> SendVerifyCodeAsync(SendVerifyCodeReq req)
{
await _captchaCache.VerifyCaptchaAndRemoveAsync(req.VerifyCaptchaReq);
await captchaCache.VerifyCaptchaAndRemoveAsync(req.VerifyCaptchaReq);
return await Cache.SendVerifyCodeAsync(req);
}
@@ -89,7 +80,7 @@ public sealed class VerifyCodeController : ControllerBase<IVerifyCodeCache, IVer
[NonAction]
public Task<QueryVerifyCodeRsp> UpdateAsync(UpdateVerifyCodeReq req)
{
throw new NotImplementedException();
return Cache.UpdateAsync(req);
}
/// <summary>

View File

@@ -12,14 +12,9 @@ namespace NetAdmin.SysComponent.Host.Controllers.Tpl;
/// 示例服务
/// </summary>
[ApiDescriptionSettings(nameof(Tpl), Module = nameof(Tpl))]
public sealed class ExampleController : ControllerBase<IExampleCache, IExampleService>, IExampleModule
public sealed class ExampleController(IExampleCache cache) : ControllerBase<IExampleCache, IExampleService>(cache)
, IExampleModule
{
/// <summary>
/// Initializes a new instance of the <see cref="ExampleController" /> class.
/// </summary>
public ExampleController(IExampleCache cache) //
: base(cache) { }
/// <summary>
/// 批量删除示例
/// </summary>
@@ -50,7 +45,6 @@ public sealed class ExampleController : ControllerBase<IExampleCache, IExampleSe
/// <summary>
/// 示例是否存在
/// </summary>
[NonAction]
public Task<bool> ExistAsync(QueryReq<QueryExampleReq> req)
{
return Cache.ExistAsync(req);
@@ -59,7 +53,6 @@ public sealed class ExampleController : ControllerBase<IExampleCache, IExampleSe
/// <summary>
/// 获取单个示例
/// </summary>
[NonAction]
public Task<QueryExampleRsp> GetAsync(QueryExampleReq req)
{
return Cache.GetAsync(req);

View File

@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)/CodeQuality.props"/>
<Import Project="$(SolutionDir)/code.quality.props"/>
<ItemGroup>
<ProjectReference Include="../NetAdmin.Host/NetAdmin.Host.csproj"/>
<ProjectReference Include="../NetAdmin.SysComponent.Cache/NetAdmin.SysComponent.Cache.csproj"/>

View File

@@ -6,18 +6,8 @@ namespace NetAdmin.SysComponent.Host.Subscribers;
/// <summary>
/// Api接口同步器
/// </summary>
public sealed class ApiSynchronizer : IEventSubscriber
public sealed class ApiSynchronizer(ILogger<ApiSynchronizer> logger) : IEventSubscriber
{
private readonly ILogger<ApiSynchronizer> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="ApiSynchronizer" /> class.
/// </summary>
public ApiSynchronizer(ILogger<ApiSynchronizer> logger)
{
_logger = logger;
}
/// <summary>
/// 同步Api接口
/// </summary>
@@ -26,6 +16,6 @@ public sealed class ApiSynchronizer : IEventSubscriber
{
var logService = App.GetService<IApiService>();
await logService.SyncAsync();
_logger.Info($"{nameof(IApiService)}.{nameof(IApiService.SyncAsync)} {Ln.已完成}");
logger.Info($"{nameof(IApiService)}.{nameof(IApiService.SyncAsync)} {Ln.已完成}");
}
}

View File

@@ -8,18 +8,8 @@ namespace NetAdmin.SysComponent.Host.Subscribers;
/// <summary>
/// 邮件验证码发送器
/// </summary>
public sealed class EmailCodeSender : IEventSubscriber
public sealed class EmailCodeSender(ILogger<EmailCodeSender> logger) : IEventSubscriber
{
private readonly ILogger<EmailCodeSender> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="EmailCodeSender" /> class.
/// </summary>
public EmailCodeSender(ILogger<EmailCodeSender> logger)
{
_logger = logger;
}
/// <summary>
/// 发送邮件
/// </summary>
@@ -35,6 +25,6 @@ public sealed class EmailCodeSender : IEventSubscriber
var verifyCodeService = App.GetService<IVerifyCodeService>();
_ = await verifyCodeService.UpdateAsync(
verifyCodeCreatedEvent.Data.Adapt<UpdateVerifyCodeReq>() with { Status = VerifyCodeStatues.Sent });
_logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已完成}");
logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已完成}");
}
}

View File

@@ -8,18 +8,8 @@ namespace NetAdmin.SysComponent.Host.Subscribers;
/// <summary>
/// 短信验证码发送器
/// </summary>
public sealed class SmsCodeSender : IEventSubscriber
public sealed class SmsCodeSender(ILogger<SmsCodeSender> logger) : IEventSubscriber
{
private readonly ILogger<SmsCodeSender> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="SmsCodeSender" /> class.
/// </summary>
public SmsCodeSender(ILogger<SmsCodeSender> logger)
{
_logger = logger;
}
/// <summary>
/// 发送短信
/// </summary>
@@ -35,6 +25,6 @@ public sealed class SmsCodeSender : IEventSubscriber
var verifyCodeService = App.GetService<IVerifyCodeService>();
_ = await verifyCodeService.UpdateAsync(
verifyCodeCreatedEvent.Data.Adapt<UpdateVerifyCodeReq>() with { Status = VerifyCodeStatues.Sent });
_logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已完成}");
logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已完成}");
}
}