

using DFS.Core.Mvc;
using DFS.Infrastructure.Redis.Extension;
using FreeSql;
using Fuel.Application;
using Fuel.Application.Repositories;
using Fuel.Application.Service;
using Fuel.Infrastructure;
using Fuel.Payment.Service.AliPaymentProcessor.Alipay;
using Fuel.Payment.Service.AllInPayProcessor.AllInPay;
using Fuel.Payment.Service.Factory;
using Fuel.Payment.Service.Pay;
using Fuel.Payment.Service.UnionPayProcessor;
using Fuel.PaymentServer.MicServer;
using Fuel.Infrastructure.Extension;
using CSRedis;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<IPayService, PayService>();
AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "ALI_SCAN", new AlipayPaymentProcessor());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "WX_SCAN", new WechatPaymentProcessor());
AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "ALL_IN_SCAN", new AllInPayProcessor());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "ALL_IN_SCAN_V2", new AllInPayProcessorV2());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "WX_ORDER_SCAN", new WechatPaymentProcessor());
AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "ALI_ORDER_SCAN", new AlipayPaymentProcessor());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "WECHAT_MINIPROGRAM_PAY", new WechatPaymentProcessor());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "ICBC_SCAN", new IcbcPayProcessor());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "ICBC_ORDER_SCAN", new IcbcPayProcessor());
//AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "GRG_SCAN", new GrgPayProcessor());
AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "UNION_MINI", new MiniUnionPayProcessor());
AsyncPaymentProcessorFactory.Default.Regist(o => o.Channel == "UNION_SCAN", new UnionPayProcessor());
// Add services to the container.
// Ìí¼ÓFreeSQLÅäÖÃ
builder.Services.AddFreeSql(builder.Configuration);

//³õÊ¼»¯DFS Server
builder.Services.AddMicService(builder.Environment);

builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<INozzleRepository, NozzleRepository>();
builder.Services.AddScoped<INozzleService, NozzleService>();
builder.Services.AddScoped<ITransactionsService, TransactionsService>();

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

Fuel.Infrastructure.Extension.RedisOptions redisOptions = builder.Configuration.GetSection("Redis").Get<Fuel.Infrastructure.Extension.RedisOptions>();
builder.Services.UseRedisClient(redisOptions);
var app = builder.Build();



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

app.UseDFSServer();

app.UseHttpsRedirection();

app.UseAuthentication();

app.UseAuthorization();

app.MapControllers();

app.Run();
