debug
This commit is contained in:
parent
f5d6e0652c
commit
28de202556
@ -19,6 +19,8 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
|
||||||
|
<PackageReference Include="NetCorePal.Extensions.AspNetCore" />
|
||||||
|
<PackageReference Include="NetCorePal.Extensions.DistributedLocks.Redis" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
|
||||||
<PackageReference Include="OpenIddict.Abstractions" />
|
<PackageReference Include="OpenIddict.Abstractions" />
|
||||||
<PackageReference Include="OpenIddict.AspNetCore" />
|
<PackageReference Include="OpenIddict.AspNetCore" />
|
||||||
|
|||||||
42
Program.cs
42
Program.cs
@ -11,6 +11,7 @@ using System.Text;
|
|||||||
using Fengling.Console.Datas;
|
using Fengling.Console.Datas;
|
||||||
using Fengling.Console.Models.Entities;
|
using Fengling.Console.Models.Entities;
|
||||||
using Fengling.Platform.Infrastructure;
|
using Fengling.Platform.Infrastructure;
|
||||||
|
using NetCorePal.Extensions.DependencyInjection;
|
||||||
using OpenIddict.Validation.AspNetCore;
|
using OpenIddict.Validation.AspNetCore;
|
||||||
using YarpGateway.Data;
|
using YarpGateway.Data;
|
||||||
|
|
||||||
@ -48,10 +49,7 @@ builder.Services.AddScoped<IGatewayService, GatewayService>();
|
|||||||
builder.Services.AddScoped<IH5LinkService, H5LinkService>();
|
builder.Services.AddScoped<IH5LinkService, H5LinkService>();
|
||||||
|
|
||||||
builder.Services.AddOpenIddict()
|
builder.Services.AddOpenIddict()
|
||||||
.AddCore(options =>
|
.AddCore(options => { options.UseEntityFrameworkCore().UseDbContext<ApplicationDbContext>(); })
|
||||||
{
|
|
||||||
options.UseEntityFrameworkCore().UseDbContext<ApplicationDbContext>();
|
|
||||||
})
|
|
||||||
.AddValidation(options =>
|
.AddValidation(options =>
|
||||||
{
|
{
|
||||||
options.SetIssuer("http://localhost:5132/");
|
options.SetIssuer("http://localhost:5132/");
|
||||||
@ -77,8 +75,8 @@ builder.Services.AddCors(options =>
|
|||||||
options.AddPolicy("AllowAll", policy =>
|
options.AddPolicy("AllowAll", policy =>
|
||||||
{
|
{
|
||||||
policy.AllowAnyOrigin()
|
policy.AllowAnyOrigin()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader();
|
.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();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(c =>
|
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Fengling.Console API V1"); });
|
||||||
{
|
|
||||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Fengling.Console API V1");
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseCors("AllowAll");
|
app.UseCors("AllowAll");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user