K7: 3个新Core接口+4条B路由+KmsAdapter多接口实现
This commit is contained in:
@@ -205,6 +205,39 @@ app.MapGet("/api/gateway/recordings/{adapter}/{deviceId}", async (string adapter
|
||||
return Results.Ok(await a.GetRecordingsAsync(deviceId, start, end, page, size));
|
||||
});
|
||||
|
||||
// B10: 设备控制 — 下发控制指令(远程开门/抬杆/授权)
|
||||
app.MapPost("/api/gateway/control/{adapter}", async (string adapter, ControlRequest req) =>
|
||||
{
|
||||
var a = registry.FindByCode<IAcceptsControl>(adapter);
|
||||
if (a == null) return Results.NotFound(new { error = "CAPABILITY_NOT_SUPPORTED" });
|
||||
var result = await a.SendControlAsync(req.DeviceId ?? "", req.Command ?? "open", req.Parameters ?? new());
|
||||
return result.Success ? Results.Ok(result) : Results.Problem(result.Message, statusCode: 502);
|
||||
});
|
||||
|
||||
// B11: 业务记录查询 — 借还/交接/授权记录
|
||||
app.MapGet("/api/gateway/logs/{adapter}", async (string adapter, string logType, DateTime? from, DateTime? to, int page, int size) =>
|
||||
{
|
||||
var a = registry.FindByCode<IHasBusinessLogs>(adapter);
|
||||
if (a == null) return Results.NotFound(new { error = "CAPABILITY_NOT_SUPPORTED" });
|
||||
return Results.Ok(await a.GetBusinessLogsAsync(logType, from, to, page, size));
|
||||
});
|
||||
|
||||
// B12: 数据同步 — 向子系统写入数据(员工同步)
|
||||
app.MapPost("/api/gateway/sync/{adapter}", async (string adapter, SyncRequest req) =>
|
||||
{
|
||||
var a = registry.FindByCode<IAcceptsDataSync>(adapter);
|
||||
if (a == null) return Results.NotFound(new { error = "CAPABILITY_NOT_SUPPORTED" });
|
||||
return Results.Ok(await a.SyncDataAsync(req.DataType ?? "staff", req.Items ?? new()));
|
||||
});
|
||||
|
||||
// B13: 数据删除 — 从子系统删除数据
|
||||
app.MapDelete("/api/gateway/sync/{adapter}", async (string adapter, SyncDeleteRequest req) =>
|
||||
{
|
||||
var a = registry.FindByCode<IAcceptsDataSync>(adapter);
|
||||
if (a == null) return Results.NotFound(new { error = "CAPABILITY_NOT_SUPPORTED" });
|
||||
return Results.Ok(await a.DeleteDataAsync(req.DataType ?? "staff", req.Ids ?? new()));
|
||||
});
|
||||
|
||||
// B3: 手动同步 — 触发适配器全量设备同步
|
||||
app.MapPost("/api/gateway/devices/sync", async (string adapter) =>
|
||||
{
|
||||
@@ -270,3 +303,6 @@ record PtzRequest(string? Direction, string Action, float Speed);
|
||||
/// <param name="PointIndex">点位索引</param>
|
||||
/// <param name="Value">目标值</param>
|
||||
record ControlRequest(string? DeviceId, int PointIndex, double Value);
|
||||
record GatewayControlRequest(string? DeviceId, string? Command, Dictionary<string, object?>? Parameters);
|
||||
record SyncRequest(string? DataType, List<object>? Items);
|
||||
record SyncDeleteRequest(string? DataType, List<string>? Ids);
|
||||
|
||||
Reference in New Issue
Block a user