2021-12-25 14:50:54 +08:00
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
|
using Yi.Framework.WebCore.BuilderExtend;
|
|
|
|
|
|
using Yi.Framework.Core;
|
|
|
|
|
|
using Yi.Framework.WebCore.MiddlewareExtend;
|
|
|
|
|
|
using Yi.Framework.WebCore.Utility;
|
|
|
|
|
|
using Autofac;
|
2022-04-02 17:44:50 +08:00
|
|
|
|
using Yi.Framework.Common.Models;
|
2022-04-03 23:21:53 +08:00
|
|
|
|
using Yi.Framework.Language;
|
|
|
|
|
|
using Microsoft.Extensions.Localization;
|
2022-04-06 22:22:45 +08:00
|
|
|
|
using Yi.Framework.WebCore.AttributeExtend;
|
2021-12-25 14:50:54 +08:00
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
2022-04-03 23:21:53 +08:00
|
|
|
|
builder.Configuration.AddCommandLine(args);
|
|
|
|
|
|
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
|
2021-12-25 14:50:54 +08:00
|
|
|
|
builder.Host.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
configurationBuilder.AddCommandLine(args);
|
|
|
|
|
|
configurationBuilder.AddJsonFileService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Apollo<6C><6F><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
configurationBuilder.AddApolloService("Yi");
|
|
|
|
|
|
});
|
|
|
|
|
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
|
|
|
|
|
builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Module<6C><65><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
containerBuilder.RegisterModule<CustomAutofacModule>();
|
|
|
|
|
|
});
|
|
|
|
|
|
builder.Host.ConfigureLogging(loggingBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
|
|
|
|
|
|
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
|
2022-04-03 23:21:53 +08:00
|
|
|
|
loggingBuilder.AddLog4Net("./Config/Log4net.config");
|
|
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
});
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
//builder.Host.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// //webBuilder.UseStartup<Startup>();
|
|
|
|
|
|
// });
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Ioc<6F><63><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddIocService(builder.Configuration);
|
|
|
|
|
|
#region
|
2022-04-06 22:22:45 +08:00
|
|
|
|
//Sqlsugar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSqlsugarServer();
|
|
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//Quartz<74><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddQuartzService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddControllers(optios => {
|
2022-04-06 22:22:45 +08:00
|
|
|
|
//optios.Filters.Add<PermissionAttribute>();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
}).AddJsonFileService();
|
|
|
|
|
|
#region
|
2022-04-06 22:22:45 +08:00
|
|
|
|
//Ȩ<><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSingleton<PermissionAttribute>();
|
|
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSwaggerService<Program>();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddCorsService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddJwtService();
|
|
|
|
|
|
#region
|
2022-01-11 16:40:15 +08:00
|
|
|
|
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddAuthorizationService();
|
|
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//Redis<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddRedisService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//RabbitMQ<4D><51><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddRabbitMQService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//ElasticSeach<63><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddElasticSeachService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSMSService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//CAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
builder.Services.AddCAPService();
|
2022-04-03 23:21:53 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD>ʻ<EFBFBD><CABB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddLocalizerService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
var app = builder.Build();
|
2022-04-02 17:44:50 +08:00
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
ServiceLocator.Instance = app.Services;
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//if (app.Environment.IsDevelopment())
|
|
|
|
|
|
{
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Swagger<65><72><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseSwaggerService();
|
|
|
|
|
|
}
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
app.UseErrorHandlingService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
app.UseStaticFiles();
|
2022-04-03 23:21:53 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9>ʻ<EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseLocalizerService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//HttpsRedirectionע<6E><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//·<><C2B7>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseCorsService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseHealthCheckMiddleware();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><>Ȩע<C8A8><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><>Ȩע<C8A8><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Consul<75><6C><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseConsulService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//redis<69><73><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
app.UseRedisSeedInitService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//Endpointsע<73><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
|
|
{
|
|
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
|
});
|
|
|
|
|
|
app.Run();
|