feat: 新增设备绑定、扫码与联系人管理功能
This commit is contained in:
@@ -26,6 +26,41 @@ class DeviceApi {
|
||||
}
|
||||
}
|
||||
|
||||
/// 绑定设备(手动输入 SN 或扫码得到 SN 后调用)。
|
||||
///
|
||||
/// 成功返回 null;失败返回后台错误提示。
|
||||
Future<String?> bindDevice(String sn, {String? remark}) async {
|
||||
try {
|
||||
final data = await DioClient.post(
|
||||
'v1/client/sn/bind',
|
||||
queryParameters: {'sn': sn},
|
||||
data: remark != null && remark.isNotEmpty ? {'remark': remark} : null,
|
||||
);
|
||||
debugPrint('[DeviceApi] bindDevice sn=$sn data=$data');
|
||||
return null;
|
||||
} on ApiException catch (e) {
|
||||
debugPrint('[DeviceApi] bindDevice sn=$sn failed: ${e.message}');
|
||||
return e.message;
|
||||
}
|
||||
}
|
||||
|
||||
/// 解绑设备。
|
||||
///
|
||||
/// 成功返回 null;失败返回后台错误提示。
|
||||
Future<String?> unbindDevice(String sn) async {
|
||||
try {
|
||||
final data = await DioClient.post(
|
||||
'v1/client/sn/unbind',
|
||||
queryParameters: {'sn': sn},
|
||||
);
|
||||
debugPrint('[DeviceApi] unbindDevice sn=$sn data=$data');
|
||||
return null;
|
||||
} on ApiException catch (e) {
|
||||
debugPrint('[DeviceApi] unbindDevice sn=$sn failed: ${e.message}');
|
||||
return e.message;
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取已绑定设备基本信息(无上报数据时返回 null)。
|
||||
Future<DeviceSystemInfo?> getDeviceInfo(String sn) async {
|
||||
try {
|
||||
@@ -160,4 +195,36 @@ class DeviceApi {
|
||||
);
|
||||
}).toList(growable: false);
|
||||
}
|
||||
|
||||
/// 删除单张设备截图(家属端 client 接口)。
|
||||
///
|
||||
/// [sn] 设备序列号,[id] 截图ID。成功返回 null;失败返回后台错误提示。
|
||||
Future<String?> deleteScreenshot(String sn, int id) async {
|
||||
try {
|
||||
await DioClient.delete(
|
||||
'v1/client/sn/ops/screenshots/$id?sn=${Uri.encodeQueryComponent(sn)}',
|
||||
);
|
||||
debugPrint('[DeviceApi] deleteScreenshot sn=$sn id=$id success');
|
||||
return null;
|
||||
} on ApiException catch (e) {
|
||||
debugPrint('[DeviceApi] deleteScreenshot sn=$sn id=$id failed: ${e.message}');
|
||||
return e.message;
|
||||
}
|
||||
}
|
||||
|
||||
/// 清空设备全部截图(家属端 client 接口)。
|
||||
///
|
||||
/// [sn] 设备序列号。成功返回 null;失败返回后台错误提示。
|
||||
Future<String?> clearScreenshots(String sn) async {
|
||||
try {
|
||||
await DioClient.delete(
|
||||
'v1/client/sn/ops/screenshots?sn=${Uri.encodeQueryComponent(sn)}',
|
||||
);
|
||||
debugPrint('[DeviceApi] clearScreenshots sn=$sn success');
|
||||
return null;
|
||||
} on ApiException catch (e) {
|
||||
debugPrint('[DeviceApi] clearScreenshots sn=$sn failed: ${e.message}');
|
||||
return e.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user