路径规划作业列表 其余界面优化
This commit is contained in:
@@ -3,9 +3,8 @@ import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.
|
||||
abstract class DeviceHttpDatasource {
|
||||
Future<List<DeviceEntity>> getUserDevices(String username);
|
||||
Future<int> bindDevice(String deviceId, String deviceAlias);
|
||||
Future<int> unbindDevice(String deviceId);
|
||||
Future<int> unbindDevice(String deviceId, String deviceName);
|
||||
Future<int> switchDevice(String platform, String deviceId);
|
||||
|
||||
Future<dynamic> getDeviceLocation(String username) async {}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,9 +76,23 @@ class DeviceHttpDatasourceImpl implements DeviceHttpDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> unbindDevice(String deviceId) {
|
||||
// TODO: implement unbindDevice
|
||||
throw UnimplementedError();
|
||||
Future<int> unbindDevice(String deviceId, String deviceName) async {
|
||||
final response = await dio.post(
|
||||
'/forward/device/unbind',
|
||||
data: {"deviceId": deviceId, "deviceName": deviceName},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络错误');
|
||||
}
|
||||
|
||||
if (data['code'] != 200) {
|
||||
throw Exception(data['msg']);
|
||||
}
|
||||
|
||||
return data['data'];
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -101,14 +115,13 @@ class DeviceHttpDatasourceImpl implements DeviceHttpDatasource {
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
if (data['code'] == 200) {
|
||||
//return data['data']; // 返回设备数据
|
||||
final locationData = data['data'];// 假设数据结构,测试时候如有不妥就修改结果的实例化
|
||||
//return data['data']; // 返回设备数据
|
||||
final locationData = data['data']; // 假设数据结构,测试时候如有不妥就修改结果的实例化
|
||||
return DeviceLocationEntity(
|
||||
deviceName: locationData['deviceName'],
|
||||
latitude: locationData['latitude'],
|
||||
longitude: locationData['longitude'],
|
||||
);
|
||||
|
||||
} else {
|
||||
throw Exception(data['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user