build: 升级目标框架到net10.0并完善模板配置

1. 将Hua.Cli.Tests、项目共享库、模块项目等所有项目的TargetFramework从net8.0/net9.0升级到net10.0
2. 完善dotnet-tools.json、模板配置文件,添加必要的构建和发布配置
3. 新增微服务、网关、应用程序的启动脚本和基础配置文件
4. 补充产品管理模块的领域、应用、Web层基础代码和多语言资源
This commit is contained in:
ShaoHua
2026-07-16 02:43:29 +08:00
parent 2a6f5f81b7
commit 734b2c91f9
264 changed files with 7132 additions and 451 deletions
@@ -0,0 +1,146 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using ProductManagement;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Identity;
using Volo.Abp.IdentityModel;
using Volo.Abp.TenantManagement;
namespace Company.Project.ConsoleClientDemo;
public class ClientDemoService : ITransientDependency
{
private readonly IIdentityUserAppService _userAppService;
private readonly ITenantAppService _tenantAppService;
private readonly IProductAppService _productAppService;
private readonly IIdentityModelAuthenticationService _authenticator;
private readonly AbpRemoteServiceOptions _remoteServiceOptions;
public ClientDemoService(
IIdentityUserAppService userAppService,
IProductAppService productAppService,
IIdentityModelAuthenticationService authenticator,
IOptions<AbpRemoteServiceOptions> remoteServiceOptions,
ITenantAppService tenantAppService)
{
_userAppService = userAppService;
_authenticator = authenticator;
_tenantAppService = tenantAppService;
_remoteServiceOptions = remoteServiceOptions.Value;
_productAppService = productAppService;
}
public async Task RunAsync()
{
await TestWithHttpClient();
await TestIdentityService();
await TestTenantManagementService();
await TestProductService();
}
private async Task TestWithHttpClient()
{
Console.WriteLine();
Console.WriteLine("*** TestWithHttpClient ************************************");
try
{
using (var client = new HttpClient())
{
await _authenticator.TryAuthenticateAsync(client);
var url = GetServerUrl() + "Test/Index";
var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
Console.WriteLine(response.StatusCode);
}
else
{
var responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private async Task TestIdentityService()
{
Console.WriteLine();
Console.WriteLine("*** TestIdentityService ************************************");
try
{
var output = await _userAppService.GetListAsync(new GetIdentityUsersInput());
Console.WriteLine("Total user count: " + output.TotalCount);
foreach (var user in output.Items)
{
Console.WriteLine($"- UserName={user.UserName}, Email={user.Email}, Name={user.Name}, Surname={user.Surname}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private async Task TestTenantManagementService()
{
Console.WriteLine();
Console.WriteLine("*** TestTenantManagementService ************************************");
try
{
var output = await _tenantAppService.GetListAsync(new GetTenantsInput());
Console.WriteLine("Total tenant count: " + output.TotalCount);
foreach (var tenant in output.Items)
{
Console.WriteLine($"- Id={tenant.Id}, Name={tenant.Name}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private async Task TestProductService()
{
Console.WriteLine();
Console.WriteLine("*** TestProductService ************************************");
try
{
var output = await _productAppService.GetListAsync();
Console.WriteLine("Total product count: " + output.Items.Count);
foreach (var product in output.Items)
{
Console.WriteLine($"- Code={product.Code}, Name={product.Name}, Price={product.Price}, StockCount={product.StockCount}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private string GetServerUrl()
{
return _remoteServiceOptions.RemoteServices.Default.BaseUrl.EnsureEndsWith('/');
}
}
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>Company.Project.ConsoleClientDemo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Autofac" Version="9.0.0" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="9.0.0" />
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="9.0.0" />
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi.Client" Version="9.0.0" />
<ProjectReference Include="..\..\modules\product\src\ProductManagement.HttpApi.Client\ProductManagement.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
@@ -0,0 +1,31 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
namespace Company.Project.ConsoleClientDemo;
public class ConsoleClientDemoHostedService : IHostedService
{
public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<ConsoleClientDemoModule>(options =>
{
options.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.AddSerilog(dispose: true);
});
}))
{
application.Initialize();
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
await demo.RunAsync();
application.Shutdown();
}
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
@@ -0,0 +1,20 @@
using ProductManagement;
using Volo.Abp.Autofac;
using Volo.Abp.Http.Client.IdentityModel;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.TenantManagement;
namespace Company.Project.ConsoleClientDemo;
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpHttpClientIdentityModelModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(ProductManagementHttpApiClientModule),
typeof(AbpTenantManagementHttpApiClientModule)
)]
public class ConsoleClientDemoModule : AbpModule
{
}
@@ -0,0 +1,31 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace Company.Project.ConsoleClientDemo;
internal class Program
{
static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.File("Logs/logs.txt")
.CreateLogger();
Log.Information("Starting ConsoleClientDemo...");
await CreateHostBuilder(args).RunConsoleAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<ConsoleClientDemoHostedService>();
});
}
@@ -0,0 +1,17 @@
{
"RemoteServices": {
"Default": {
"BaseUrl": "https://localhost:44329/"
}
},
"IdentityClients": {
"Default": {
"GrantType": "client_credentials",
"ClientId": "console-client-demo",
"ClientSecret": "1q2w3e*",
"Authority": "https://localhost:44399",
"RequireHttpsMetadata": "true",
"Scope": "InternalGateway IdentityService ProductService"
}
}
}