对接fake admin

This commit is contained in:
xiaolipro 2025-12-26 14:59:38 +08:00
parent 9b28998dcc
commit 8a7c1b895a
7 changed files with 29 additions and 25 deletions

6
Directory.Build.props Normal file
View File

@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<!-- All Fake packages -->
<FakePackageVersion>8.0.0-preview21</FakePackageVersion>
</PropertyGroup>
</Project>

View File

@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution
.gitignore = .gitignore .gitignore = .gitignore
global.json = global.json global.json = global.json
docker-compose.yml = docker-compose.yml docker-compose.yml = docker-compose.yml
Directory.Build.props = Directory.Build.props
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Repositories", "src\InterfaceForward.Repositories\InterfaceForward.Repositories.csproj", "{AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Repositories", "src\InterfaceForward.Repositories\InterfaceForward.Repositories.csproj", "{AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23}"

View File

@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" /> <ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/> <ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/>
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview18" /> <PackageReference Include="Fake.Autofac" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.21" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.21" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.18" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.18" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />

View File

@ -1,10 +1,12 @@
using Fake.AspNetCore; using Fake.AspNetCore;
using Fake.AspNetCore.Auditing; using Fake.AspNetCore.Auditing;
using Fake.AspNetCore.Mvc;
using Fake.AspNetCore.Mvc.Conventions; using Fake.AspNetCore.Mvc.Conventions;
using Fake.AspNetCore.Mvc.Filters; using Fake.AspNetCore.Mvc.Filters;
using Fake.Authorization; using Fake.Authorization;
using Fake.Autofac; using Fake.Autofac;
using Fake.Modularity; using Fake.Modularity;
using Fake.Security.Claims;
using InterfaceForward.Application; using InterfaceForward.Application;
using InterfaceForward.Application.Filters; using InterfaceForward.Application.Filters;
using InterfaceForward.Domain.Shared; using InterfaceForward.Domain.Shared;
@ -24,6 +26,12 @@ namespace InterfaceForward.Api;
public class InterfaceForwardApiModule : FakeModule public class InterfaceForwardApiModule : FakeModule
{ {
private const string DefaultCorsPolicyName = "default"; private const string DefaultCorsPolicyName = "default";
public override void PreConfigureServices(ServiceConfigurationContext context)
{
FakeClaimTypes.UserId = "mapId";
}
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var services = context.Services; var services = context.Services;
@ -32,9 +40,9 @@ public class InterfaceForwardApiModule : FakeModule
// Add services to the container. // Add services to the container.
services.AddProblemDetails(); services.AddProblemDetails();
services.Configure<ApplicationService2ControllerOptions>(options => services.Configure<FakeAspNetCoreMvcOptions>(options =>
{ {
options.ScanApplicationServices<InterfaceForwardApplicationModule>(); options.ApplicationServices2Controller<InterfaceForwardApplicationModule>();
}); });
// 全局授权配置:所有接口默认需要授权 // 全局授权配置:所有接口默认需要授权
@ -80,10 +88,7 @@ public class InterfaceForwardApiModule : FakeModule
} }
}); });
}) })
.AddFakeExceptionFilter() .AddFakeAspNetCoreAuditing();
.AddFakeValidationActionFilter()
.AddFakeAspNetCoreAuditing()
.AddFakeUnitOfWorkActionFilter();
services.AddCors(options => services.AddCors(options =>
{ {
@ -105,15 +110,7 @@ public class InterfaceForwardApiModule : FakeModule
options.KnownProxies.Clear(); options.KnownProxies.Clear();
}); });
services.AddAuthentication(options => services.AddFakeJwtAuthentication();
{
options.DefaultAuthenticateScheme = "Bearer";
options.DefaultChallengeScheme = "Bearer";
}).AddJwtBearer(options =>
{
var jwtSettings = configuration.GetSection("JWTSettings").Get<JWTSettingsOptions>();
options.TokenValidationParameters = JWTEncryption.CreateTokenValidationParameters(jwtSettings);
});
// 添加授权服务 // 添加授权服务
services.AddAuthorization(); services.AddAuthorization();

View File

@ -14,13 +14,13 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DiffPlex" Version="1.7.2" /> <PackageReference Include="DiffPlex" Version="1.9.0" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" /> <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
<PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.2.2.1"/> <PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.2.2.1"/>
<PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview18" /> <PackageReference Include="Fake.AspNetCore" Version="8.0.0" />
<PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0-preview18" /> <PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0" />
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview18" /> <PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0" />
<PackageReference Include="FreeRedis" Version="1.3.6" /> <PackageReference Include="FreeRedis" Version="1.5.5" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -5,12 +5,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Serilog" Version="4.2.1-dev-02337" /> <PackageReference Include="Serilog" Version="4.2.1-dev-02337" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview18" /> <PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.0-preview18" /> <PackageReference Include="Fake.SqlSugarCore" Version="8.0.0" />
<PackageReference Include="NEST" Version="7.17.5" /> <PackageReference Include="NEST" Version="7.17.5" />
</ItemGroup> </ItemGroup>