Bizer.AspNetCore
0.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Bizer.AspNetCore --version 0.1.0
NuGet\Install-Package Bizer.AspNetCore -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bizer.AspNetCore" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bizer.AspNetCore --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bizer.AspNetCore, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Bizer.AspNetCore as a Cake Addin #addin nuget:?package=Bizer.AspNetCore&version=0.1.0 // Install Bizer.AspNetCore as a Cake Tool #tool nuget:?package=Bizer.AspNetCore&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bizer
业务开发人员再也不用担心前后端对接的事情,一个接口,前后端全自动对接。
⚠️ 定义服务接口和 HTTP 路由规则
安装 Bizer
包
> Install-Package Bizer
定义业务接口
[ApiRoute("api/account")] //定义 API 的路由,类似于 Controller
public interface IAccountService
{
[Post] //定义为 Post 请求
Task<Returns<string>> SignInAsync([Form]string userName, [Form]string password); //参数使用 form 方式
}
就像平时那样的实现自己的业务逻辑即可
public class AccountApplicationService : IAccountService
{
public Task<Returns<string>> SignInAsync(string userName, string password)
{
//业务逻辑代码
return Returns<string>.Success(token);
}
}
📌 在 AspNetCore 项目中
安装 Bizer.AspNetCore
包
> Install-Package Bizer.AspNetCore
配置服务,自动发现并秒变 API
builder.Services.AddBizerOpenApi(configure => {
configure.Add(typeof(IAccountService).Assembly);//需要秒变 API 的程序集
//or
configure.Add("MyNamespace.MyService.*"); //自动搜索程序集,支持通配符
});
配置中间件,内置 Swagger
app.UseBizerOpenApi();
最后启动并访问你的 swagger http://{localhost:port}/swagger
🛡️ 在任意客户端项目,例如 Console/Blazor 等
安装 Bizer.Client
包
> Install-Package Bizer.Client
注册客户端服务
builder.Services.AddBizerClient(configure => {
configure.Add(typeof(IAccountService).Assembly);//已知程序集
//or
configure.Add("MyNamespace.MyService.*"); //自动搜索程序集,支持通配符
});
调用方法即可自动发送 HTTP 请求
private readonly IAccountService _accountService;
public MyClientService(IAccountService accountService)
{
_accountService = accountService;
}
//...
var result = _accountService.SignInAsync("admin", "password");
if(!result.Succeed)
{
//result.Errors 获取错误信息
}
var data = result.Data; //获取数据
💻 支持环境
- .NET 6
- .NET 7
⛔ 使用限制
- 方法必须要有返回类型,推荐使用
Returns
或Returns<TResult>
类型 - 不支持同步方法
📃 许可证
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Bizer (>= 0.1.0)
- NSwag.AspNetCore (>= 13.19.0)
-
net7.0
- Bizer (>= 0.1.0)
- NSwag.AspNetCore (>= 13.19.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.