使用 maf重构

This commit is contained in:
孙诚
2026-01-12 14:34:03 +08:00
parent 255c82759e
commit db61f70335
20 changed files with 1632 additions and 27 deletions

View File

@@ -1,3 +1,5 @@
using System.Text;
using Microsoft.Agents.AI;
using FreeSql;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
@@ -33,6 +35,10 @@ builder.Services.AddControllers(options =>
builder.Services.AddOpenApi();
builder.Services.AddHttpClient();
// 注册 Agent Framework
builder.Services.AddAgentFramework();
#if DEBUG
// 配置 CORS
builder.Services.AddCors(options =>
{
@@ -43,6 +49,7 @@ builder.Services.AddCors(options =>
.AllowAnyMethod();
});
});
#endif
// 绑定配置
builder.Services.Configure<EmailSettings>(builder.Configuration.GetSection("EmailSettings"));
@@ -111,7 +118,7 @@ var fsql = new FreeSqlBuilder()
.UseMonitorCommand(
cmd =>
{
Log.Debug("执行SQL: {Sql}", cmd.CommandText);
Log.Verbose("执行SQL: {Sql}", cmd.CommandText);
}
)
.Build();
@@ -121,6 +128,9 @@ builder.Services.AddSingleton(fsql);
// 自动扫描注册服务和仓储
builder.Services.AddServices();
// 注册 Agent Framework
builder.Services.AddAgentFramework();
// 注册日志清理后台服务
builder.Services.AddHostedService<LogCleanupService>();