Bizer.Client 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bizer.Client --version 0.2.0                
NuGet\Install-Package Bizer.Client -Version 0.2.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.Client" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bizer.Client --version 0.2.0                
#r "nuget: Bizer.Client, 0.2.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.Client as a Cake Addin
#addin nuget:?package=Bizer.Client&version=0.2.0

// Install Bizer.Client as a Cake Tool
#tool nuget:?package=Bizer.Client&version=0.2.0                

Bizer

logo

业务开发人员再也不用担心前后端对接的事情,一个接口,前后端全自动对接。

⚠️ 定义服务接口和 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
	.AddBizer(options => options.Assemblies.Add(typeof(IAccountService).Assembly))
	.AddApiConvension();

配置中间件,内置 Swagger

app.UseBizerOpenApi();

最后启动并访问你的 swagger http://{localhost:port}/swagger

🛡️ 在任意客户端项目,例如 Console/Blazor 等

安装 Bizer.Client

> Install-Package Bizer.Client

注册客户端服务

builder.Services
	.AddBizer(options => options.Assemblies.Add(typeof(IAccountService).Assembly))
	.AddHttpClientConvension("http://localhost:port");

调用方法即可自动发送 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; //获取数据

可以使用同样的方式访问各大 OPEN API 平台,例如微信公众平台、支付宝商户平台等等

💻 支持环境

  • .NET 6
  • .NET 7

📃 许可证

Apache License 2.0

Product 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.8.0-preview1 134 1/19/2024
0.7.0 202 1/9/2024
0.6.1 151 12/26/2023
0.6.0 133 9/4/2023
0.5.0.1 139 8/29/2023
0.5.0 161 8/4/2023
0.4.0 171 7/28/2023
0.3.0 148 7/20/2023
0.2.0 157 7/15/2023
0.1.0 169 7/13/2023