Moka 基于 Moka HR 开放平台 API,实现 IHumanResourcesService 统一接口。
包信息
| 项 | 值 |
|---|---|
| NuGet 包 | Bitzsoft.Integrations.HumanResources.Moka |
| 实现接口 | IHumanResourcesService |
| Provider ID | moka |
| 鉴权方式 | HTTP Basic Auth(API Key + Secret) |
| 默认 ApiBaseUrl | https://api.mokahr.com/api |
| 区域 | Global |
凭据(API Key + Secret)在 Moka 开放平台后台创建应用后获取。
配置字段
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
ApiBaseUrl | string | 否 | https://api.mokahr.com/api | Moka 开放平台基地址 |
ApiKey | string | 是 | — | API Key(Basic Auth 用户名) |
ApiSecret | string | 是 | — | API Secret(Basic Auth 密码) |
HttpClientName | string | 否 | HumanResourcesMoka | 业务 HttpClient 命名 |
配置 JSON 示例
{ "HumanResources": { "Moka": { "ApiBaseUrl": "https://api.mokahr.com/api", "ApiKey": "xxxxxxxxxxxx", "ApiSecret": "xxxxxxxxxxxxxxxxxxxxxxxx" } }}DI 注册
// 从配置节注册(默认节名 HumanResources:Moka)services.AddMokaHumanResources(configuration);
// 或用回调单独配置services.AddMokaHumanResources(options =>{ options.ApiKey = "xxxxxxxxxxxx"; options.ApiSecret = "xxxxxxxxxxxxxxxxxxxxxxxx";});使用示例
public class EmployeeService{ private readonly IHumanResourcesService _hr;
public EmployeeService(IHumanResourcesService hr) => _hr = hr;
public Task<HrEmployee> OnboardAsync(string name, string email, string departmentId) => _hr.CreateEmployeeAsync(new CreateEmployeeRequest { Name = name, Email = email, DepartmentId = departmentId });
public Task<HrResult> OffboardAsync(string employeeId) => _hr.DeactivateEmployeeAsync(employeeId);}依赖
| 包 | 说明 |
|---|---|
Bitzsoft.Integrations.HumanResources | 人力资源服务抽象层 |
Bitzsoft.Integrations.Core | 公共基座 |
已知限制
- Basic Auth 凭据为长期凭据,请妥善保管。