Bizer 0.1.0

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

// Install Bizer as a Cake Tool
#tool nuget:?package=Bizer&version=0.1.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.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

⛔ 使用限制

  • 方法必须要有返回类型,推荐使用 ReturnsReturns<TResult> 类型
  • 不支持同步方法

📃 许可证

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 (2)

Showing the top 2 NuGet packages that depend on Bizer:

Package Downloads
Bizer.Services

基于 EntityFrameworkCore 作为 ORM,使用 Mapster 作为映射,实现基本的 CRUD 功能。

Bizer.Localization

使用 JSON 文件作为本地化资源文件。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.7.0 313 1/9/2024
0.6.1 290 12/26/2023
0.6.0 284 9/4/2023
0.5.0.1 272 8/29/2023
0.5.0 302 8/4/2023
0.4.0 283 7/28/2023
0.3.0 286 7/20/2023
0.2.0 264 7/15/2023
0.1.0 290 7/13/2023