新增定时账单功能
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 30s
Docker Build & Deploy / Deploy to Production (push) Successful in 7s

This commit is contained in:
孙诚
2025-12-29 15:20:32 +08:00
parent 13bf23a48c
commit 9719c6043a
19 changed files with 2409 additions and 27 deletions

View File

@@ -1,10 +1,10 @@
using System.Text;
using FreeSql;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Scalar.AspNetCore;
using Serilog;
using Service.AppSettingModel;
using WebApi;
using Yitter.IdGenerator;
// 初始化雪花算法ID生成器
@@ -97,6 +97,9 @@ builder.Services.AddSingleton(fsql);
// 自动扫描注册服务和仓储
builder.Services.AddServices();
// 配置 Quartz.NET 定时任务
builder.AddScheduler();
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -122,27 +125,4 @@ app.MapControllers();
// 添加 SPA 回退路由(用于前端路由)
app.MapFallbackToFile("index.html");
// 启动后台邮件抓取服务(必须只注册一次)
app.Lifetime.ApplicationStarted.Register(() =>
{
try
{
if (app.Services.GetRequiredService<IEmailBackgroundService>() is not EmailBackgroundService emailService)
{
return;
}
// 检查是否已在运行,避免重复启动
if (!emailService.IsBusy)
{
emailService.RunWorkerAsync();
}
}
catch (Exception ex)
{
var logger = app.Services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "启动后台服务失败");
}
});
app.Run();