![]() |
VOOZH | about |
dotnet add package Galosys.Foundation.AspNetCore.DynamicApi --version 26.5.20.1
NuGet\Install-Package Galosys.Foundation.AspNetCore.DynamicApi -Version 26.5.20.1
<PackageReference Include="Galosys.Foundation.AspNetCore.DynamicApi" Version="26.5.20.1" />
<PackageVersion Include="Galosys.Foundation.AspNetCore.DynamicApi" Version="26.5.20.1" />Directory.Packages.props
<PackageReference Include="Galosys.Foundation.AspNetCore.DynamicApi" />Project file
paket add Galosys.Foundation.AspNetCore.DynamicApi --version 26.5.20.1
#r "nuget: Galosys.Foundation.AspNetCore.DynamicApi, 26.5.20.1"
#:package Galosys.Foundation.AspNetCore.DynamicApi@26.5.20.1
#addin nuget:?package=Galosys.Foundation.AspNetCore.DynamicApi&version=26.5.20.1Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.AspNetCore.DynamicApi&version=26.5.20.1Install as a Cake Tool
成熟度: 🟢 稳定 — 生产可用,测试充分,活跃维护
Galosys.Foundation.AspNetCore.DynamicApi 是 ASP.NET Core 动态 API 生成模块,通过特性标记自动将服务类转换为 RESTful API 控制器,支持自定义路由规则和统一响应模型。
[RestController] 特性自动识别服务类Async 等后缀生成简洁的 Action 名称Succeed(data) 返回标准成功响应Fail(errorCode, errorMsg) 返回标准错误响应/api/{version}/{namespace}/{controller}/{action}
v1Application、App 等后缀AppService、Service 等后缀Async 后缀dotnet add package Galosys.Foundation.AspNetCore.DynamicApi
services.AddDynamicApi(); // 注册动态 API 服务
[RestController]
public class OrderAppService
{
public async Task<OrderDto> GetOrderAsync(int id)
{
// 业务逻辑
}
public async Task<List<OrderDto>> GetOrdersAsync()
{
// 业务逻辑
}
public async Task<OrderDto> CreateOrderAsync(CreateOrderRequest request)
{
// 业务逻辑
}
}
[RestController]
public class ProductAppService : RestController
{
public UnifiedResponse GetProduct(int id)
{
var product = _repository.Get(id);
if (product == null)
return Fail(BizErrorCode.NotFound, "产品不存在");
return Succeed(product);
}
}
[RestController(CasingStrategy = CasingStrategy.KebabCase)]
public class UserAppService
{
// 路由: /api/v1/user/get-user
public async Task<UserDto> GetUserAsync(int id)
{
// 业务逻辑
}
}
[RestController(Scene = "admin", Version = "v2")]
public class AdminOrderAppService
{
// 路由: /admin/v2/admin-order/get-order
public async Task<OrderDto> GetOrderAsync(int id)
{
// 业务逻辑
}
}
| 类 | 说明 |
|---|---|
RestControllerAttribute |
标记服务类为动态 API 控制器 |
RestController |
控制器基类,提供统一响应方法 |
RestControllerConvertion |
路由约定处理器,自动生成路由 |
RestControllerFeatureProvider |
控制器特性发现提供程序 |
| 策略 | 示例路由 | 说明 |
|---|---|---|
CamelCase |
/api/v1/orderApp/getOrder |
驼峰命名 |
SnakeCase |
/api/v1/order_app/get_order |
下划线命名 |
KebabCase |
/api/v1/order-app/get-order |
短横线命名 |
[RestController(
Scene = "api", // 路由场景前缀
Version = "v1", // API 版本
CasingStrategy = CasingStrategy.KebabCase // 命名策略
)]
控制器后缀(自动移除):
AppService, AppSrv, AppSvcApplicationService, ApplicationSrv, ApplicationSvcService, Svc方法后缀(自动移除):
Async命名空间后缀(自动移除):
Application, App| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on Galosys.Foundation.AspNetCore.DynamicApi:
| Package | Downloads |
|---|---|
|
Galosys.Foundation.AspNetCore.Quartz
Galosys.Foundation快速开发库 |
|
|
Galosys.Foundation.AspNetCore.Aliyun
Galosys.Foundation快速开发库 |
|
|
Galosys.Foundation.AspNetCore.LazySlideCaptcha
Galosys.Foundation快速开发库 |
|
|
Galosys.Foundation.AspNetCore.LazyCaptcha
Galosys.Foundation快速开发库 |
|
|
Galosys.Foundation.AspNetCore.Localization
Galosys.Foundation快速开发库 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.5.20.1 | 260 | 5/20/2026 |
| 26.5.19.1 | 244 | 5/19/2026 |
| 26.5.18.1 | 249 | 5/18/2026 |
| 26.5.15.1 | 248 | 5/15/2026 |
| 26.5.12.3 | 238 | 5/12/2026 |
| 26.5.12.2 | 253 | 5/12/2026 |
| 26.4.27.1-rc1 | 208 | 4/26/2026 |
| 26.4.25.1-rc1 | 227 | 4/25/2026 |
| 26.4.22.2-rc7 | 226 | 4/22/2026 |
| 26.4.22.2-rc6 | 221 | 4/22/2026 |
| 26.4.22.2-rc4 | 224 | 4/22/2026 |
| 26.4.22.2-rc3 | 206 | 4/22/2026 |
| 26.4.19.1-rc1 | 198 | 4/19/2026 |
| 26.1.30.1-rc1 | 327 | 1/30/2026 |
| 26.1.29.1 | 332 | 1/29/2026 |
| 26.1.28.5 | 351 | 1/28/2026 |
| 26.1.28.4 | 334 | 1/28/2026 |
| 26.1.28.2 | 335 | 1/28/2026 |
| 26.1.23.6 | 327 | 1/23/2026 |
| 26.1.21.1 | 295 | 1/21/2026 |