Files
Atomx/Atomx.Core/Jos/SendVerificationCodeJob.cs
2025-12-15 13:04:44 +08:00

40 lines
1.4 KiB
C#

using Atomx.Data;
using Atomx.Data.CacheServices;
using Hangfire;
using Microsoft.Extensions.Logging;
namespace Atomx.Core.Jos
{
public class SendVerificationCodeJob
{
readonly ILogger<SendVerificationCodeJob> _logger;
readonly DataContext _dbContext;
readonly ICacheService _cacheService;
public SendVerificationCodeJob(ILogger<SendVerificationCodeJob> logger, DataContext dataContext, ICacheService cacheService)
{
_logger = logger;
_dbContext = dataContext;
_cacheService = cacheService;
}
/// <summary>
/// 发送短信验证码任务
/// </summary>
/// <param name="phone"></param>
/// <param name="code"></param>
[AutomaticRetry(Attempts = 3, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
[DisableConcurrentExecution(60)]
public void SendSMSCode(string phone, string code)
{
_logger.LogInformation("SendVerificationCodeJob executed at: {time}", DateTimeOffset.Now);
// 在这里添加发送验证码的具体任务逻辑
}
public void SendEmailCode(string email, string code)
{
_logger.LogInformation("SendVerificationCodeJob executed at: {time}", DateTimeOffset.Now);
// 在这里添加发送验证码的具体任务逻辑
}
}
}