using BAP.CAP;
using BPA.CAP.Settings;
using BPA.Component.ApolloClient;
using SqlSugar;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddApolloConfiguration(builder);

builder.Services.AddCapConfiguration(builder.Configuration,new CapSettings
{ 
    FailedThresholdCallback  = fail =>
    {
        var mess = fail.Message;
    }
});

//SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
//{
//    ConnectionString = builder.Configuration.GetSection("ConnectionStrings").Value,//连接符字串
//    DbType = DbType.SqlServer,//数据库类型
//    IsAutoCloseConnection = true //不设成true要手动close
//}
//);
//db.Aop.OnLogExecuted = (sql, pars) =>
//{

//};
//builder.Services.AddSingleton(db);
builder.Services.AddControllers();

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
    c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
