|
|
|
using Autofac;
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
using DS.Module.AutofacModule;
|
|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.Module.Core.Modules;
|
|
|
|
using DS.Module.Core.ServiceExtensions;
|
|
|
|
using DS.Module.Jwt;
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
using DS.Module.Swagger;
|
|
|
|
using DS.Module.User;
|
|
|
|
using DS.WMS.Core.DBSeed;
|
|
|
|
using DS.WMS.WebApi;
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
//Autofac注入
|
|
|
|
builder.Host
|
|
|
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
|
|
.ConfigureContainer<ContainerBuilder>(builder =>
|
|
|
|
{
|
|
|
|
builder.RegisterModule(new AutofacModuleRegister());
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
builder.Services.AddAppWebInstal();
|
|
|
|
builder.Services.AddCorsInstall();
|
|
|
|
builder.Services.AddSqlsugarInstall();
|
|
|
|
builder.Services.AddSwaggerInstall();
|
|
|
|
builder.Services.AddJwtInstall();
|
|
|
|
// builder.Services.AddApplication<DSAppWebModule>();
|
|
|
|
|
|
|
|
// 3、配置中间件
|
|
|
|
var app = builder.Build();
|
|
|
|
// app.InitializeApplication();
|
|
|
|
|
|
|
|
//if (app.Environment.IsDevelopment())
|
|
|
|
//{
|
|
|
|
// app.UseDeveloperExceptionPage();
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// app.UseExceptionHandler("/Error");
|
|
|
|
// //app.UseHsts();
|
|
|
|
//}
|
|
|
|
//swagger
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
{
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", AppSetting.Configuration["SwaggerDoc:Version"]);
|
|
|
|
});
|
|
|
|
//跨域
|
|
|
|
var policyName = AppSetting.Configuration["Cors:PolicyName"];
|
|
|
|
if (!policyName.IsNullOrEmpty())
|
|
|
|
{
|
|
|
|
app.UseCors(policyName); //添加跨域中间件
|
|
|
|
}
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
// 先开启认证
|
|
|
|
app.UseAuthentication();
|
|
|
|
// 然后是授权中间件
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
{
|
|
|
|
endpoints.MapControllers();
|
|
|
|
});
|
|
|
|
app.Run();
|