debug
This commit is contained in:
parent
f5d6e0652c
commit
28de202556
@ -19,6 +19,8 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
|
||||
<PackageReference Include="NetCorePal.Extensions.AspNetCore" />
|
||||
<PackageReference Include="NetCorePal.Extensions.DistributedLocks.Redis" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
|
||||
<PackageReference Include="OpenIddict.Abstractions" />
|
||||
<PackageReference Include="OpenIddict.AspNetCore" />
|
||||
|
||||
44
Program.cs
44
Program.cs
@ -11,6 +11,7 @@ using System.Text;
|
||||
using Fengling.Console.Datas;
|
||||
using Fengling.Console.Models.Entities;
|
||||
using Fengling.Platform.Infrastructure;
|
||||
using NetCorePal.Extensions.DependencyInjection;
|
||||
using OpenIddict.Validation.AspNetCore;
|
||||
using YarpGateway.Data;
|
||||
|
||||
@ -48,10 +49,7 @@ builder.Services.AddScoped<IGatewayService, GatewayService>();
|
||||
builder.Services.AddScoped<IH5LinkService, H5LinkService>();
|
||||
|
||||
builder.Services.AddOpenIddict()
|
||||
.AddCore(options =>
|
||||
{
|
||||
options.UseEntityFrameworkCore().UseDbContext<ApplicationDbContext>();
|
||||
})
|
||||
.AddCore(options => { options.UseEntityFrameworkCore().UseDbContext<ApplicationDbContext>(); })
|
||||
.AddValidation(options =>
|
||||
{
|
||||
options.SetIssuer("http://localhost:5132/");
|
||||
@ -77,8 +75,8 @@ builder.Services.AddCors(options =>
|
||||
options.AddPolicy("AllowAll", policy =>
|
||||
{
|
||||
policy.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
@ -95,13 +93,37 @@ builder.Services.AddSwaggerGen(c =>
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
builder.Services.AddRepositories(typeof(ApplicationDbContext).Assembly,typeof(PlatformDbContext).Assembly);
|
||||
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||
{
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("PostgreSQL"));
|
||||
// 仅在开发环境启用敏感数据日志,防止生产环境泄露敏感信息
|
||||
if (builder.Environment.IsDevelopment())
|
||||
{
|
||||
options.EnableSensitiveDataLogging();
|
||||
}
|
||||
|
||||
options.EnableDetailedErrors();
|
||||
});
|
||||
builder.Services.AddUnitOfWork<PlatformDbContext>();
|
||||
builder.Services.AddRedisLocks();
|
||||
|
||||
builder.Services.AddMediatR(cfg =>
|
||||
cfg.RegisterServicesFromAssemblies(
|
||||
Assembly.GetExecutingAssembly(),
|
||||
typeof(PlatformDbContext).Assembly
|
||||
)
|
||||
.AddCommandLockBehavior()
|
||||
.AddKnownExceptionValidationBehavior()
|
||||
.AddUnitOfWorkBehaviors());
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Fengling.Console API V1");
|
||||
});
|
||||
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Fengling.Console API V1"); });
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
@ -110,4 +132,4 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
Loading…
Reference in New Issue
Block a user