2023-10-23 17:42:37 +08:00
|
|
|
|
# SimApi 基于.Net的一个基础辅助包
|
2019-12-23 16:50:49 +08:00
|
|
|
|
|
2023-03-28 06:39:55 +08:00
|
|
|
|
[](https://github.com/simcu/simapi-net/actions/workflows/nuget-publish.yml)
|
2019-12-23 16:50:49 +08:00
|
|
|
|
### 包含了以下组件:
|
|
|
|
|
|
|
|
|
|
|
|
1. 统一的参数检测,基础认证服务
|
|
|
|
|
|
所有的控制器需要继承 YYApi.Controllers.BaseController
|
|
|
|
|
|
|
|
|
|
|
|
```C#
|
|
|
|
|
|
using Models;
|
2020-08-05 15:29:56 +08:00
|
|
|
|
using SimApi.Controllers;
|
2019-12-23 16:50:49 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Controllers
|
|
|
|
|
|
{
|
2020-08-05 15:29:56 +08:00
|
|
|
|
public class BaseController : SimApiBaseController
|
2019-12-23 16:50:49 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取登录用户信息
|
|
|
|
|
|
/// </summary>
|
2020-08-05 15:29:56 +08:00
|
|
|
|
protected SimApiLoginInfoItem LoginInfo => (SimApiLoginInfoItem) HttpContext.Items["LoginInfo"];
|
2019-12-23 16:50:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-03 13:43:46 +08:00
|
|
|
|
统一配置,现在只需要进行AddSimApi的配置, Configure中直接 UseSimApi即可。
|
2019-12-23 16:50:49 +08:00
|
|
|
|
```C#
|
2021-06-03 13:43:46 +08:00
|
|
|
|
services.AddSimApi(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.ConfigureSimApiDoc(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.ApiGroups = new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new SimApiDocGroupOption
|
|
|
|
|
|
{Id = "admin", Name = "后台管理接口", Description = "本接口调用需要Scope:sac.api.admin"},
|
|
|
|
|
|
new SimApiDocGroupOption
|
|
|
|
|
|
{Id = "user-v1", Name = "用户中心接口", Description = "本接口调用需要Scope:sac.api.user"}
|
|
|
|
|
|
};
|
|
|
|
|
|
options.ApiAuth = new SimApiAuthOption
|
|
|
|
|
|
{
|
|
|
|
|
|
Type = new[] {"ClientCredentials", "Implicit", "AuthorizationCode"},
|
|
|
|
|
|
Scopes = new Dictionary<string, string>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"sac.api.user", "用户信息接口权限"},
|
|
|
|
|
|
{"sac.api.admin", "后台管理API"}
|
|
|
|
|
|
},
|
|
|
|
|
|
AuthorizationUrl = "/connect/authorize",
|
|
|
|
|
|
TokenUrl = "/connect/token"
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
options.EnableSimApiStorage = true;
|
|
|
|
|
|
options.SimApiStorageOptions = Configuration.GetSection("S3").Get<SimApiStorageOptions>();
|
|
|
|
|
|
});
|
2019-12-23 16:50:49 +08:00
|
|
|
|
```
|
2023-10-23 17:42:37 +08:00
|
|
|
|
基于S3的存储,基于RabbitMq的事件RPC调用,自定义Logger格式,自定义响应格式
|