K4: 6个扩展方法全部就绪(记录/同步/授权/登录)
This commit is contained in:
@@ -168,4 +168,73 @@ public class KmsAdapter : IHasFlatDevices, IHasAlarms
|
|||||||
// KMS 第三方接口 (2.18.7) 不提供告警结束 API
|
// KMS 第三方接口 (2.18.7) 不提供告警结束 API
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ═══════════════════════════════════════════
|
||||||
|
// 扩展方法 — 2.18 第三方接口全覆盖
|
||||||
|
// ═══════════════════════════════════════════
|
||||||
|
|
||||||
|
/// <summary>2.18.6 查询借还记录列表</summary>
|
||||||
|
public async Task<PagedResult<KmsRecord>> GetBorrowRecordsAsync(DateTime? from = null, DateTime? to = null)
|
||||||
|
{
|
||||||
|
await _limiter.WaitAsync();
|
||||||
|
var client = await _auth.GetAuthenticatedClientAsync();
|
||||||
|
var body = "{}"; // 联调时加入时间范围参数
|
||||||
|
var resp = await client.PostAsync("/prod-api/getRecordList",
|
||||||
|
new StringContent(body, Encoding.UTF8, "application/json"));
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
var data = await resp.Content.ReadFromJsonAsync<KmsRecordListResponse>()!;
|
||||||
|
return new PagedResult<KmsRecord> { Items = data.Rows ?? new(), Total = data.Total };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>2.18.5 查询授权记录列表</summary>
|
||||||
|
public async Task<PagedResult<KmsPermission>> GetPermissionListAsync(DateTime? from = null, DateTime? to = null)
|
||||||
|
{
|
||||||
|
await _limiter.WaitAsync();
|
||||||
|
var client = await _auth.GetAuthenticatedClientAsync();
|
||||||
|
var body = "{}"; // 联调时加入时间范围
|
||||||
|
var resp = await client.PostAsync("/prod-api/getPermissionList",
|
||||||
|
new StringContent(body, Encoding.UTF8, "application/json"));
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
var data = await resp.Content.ReadFromJsonAsync<KmsPermissionListResponse>()!;
|
||||||
|
return new PagedResult<KmsPermission> { Items = data.Rows ?? new(), Total = data.Total };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>2.18.3 从 Vol.Pro 向 KMS 批量同步员工</summary>
|
||||||
|
public async Task BatchSyncStaffAsync(List<KmsStaff> staffList)
|
||||||
|
{
|
||||||
|
await _limiter.WaitAsync();
|
||||||
|
var client = await _auth.GetAuthenticatedClientAsync();
|
||||||
|
var resp = await client.PostAsJsonAsync("/prod-api/batchSyncStaff", new { staff = staffList });
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>2.18.2 从 Vol.Pro 向 KMS 批量删除员工</summary>
|
||||||
|
public async Task BatchDeleteStaffAsync(List<string> staffUuids)
|
||||||
|
{
|
||||||
|
await _limiter.WaitAsync();
|
||||||
|
var client = await _auth.GetAuthenticatedClientAsync();
|
||||||
|
var resp = await client.PostAsJsonAsync("/prod-api/batchDeleteStaff", staffUuids);
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>2.4.3 远程授权开门</summary>
|
||||||
|
public async Task RemoteAuthorizeAsync(KmsRemotePermissionRequest request)
|
||||||
|
{
|
||||||
|
await _limiter.WaitAsync();
|
||||||
|
var client = await _auth.GetAuthenticatedClientAsync();
|
||||||
|
var resp = await client.PostAsJsonAsync("/prod-api/kms/permission/remote", request);
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>2.18.8 代理 KMS 第三方登录/事件记录</summary>
|
||||||
|
public async Task<string?> ThirdPlatLoginAsync(string username)
|
||||||
|
{
|
||||||
|
await _limiter.WaitAsync();
|
||||||
|
var client = await _auth.GetAuthenticatedClientAsync();
|
||||||
|
var resp = await client.PostAsync($"/thirdPlatlogin?username={Uri.EscapeDataString(username)}", null);
|
||||||
|
if (resp.StatusCode == System.Net.HttpStatusCode.Redirect)
|
||||||
|
return resp.Headers.Location?.ToString();
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
return await resp.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user