修复一些字段不规范造成的歧义,和依赖注入问题
This commit is contained in:
@@ -3,6 +3,8 @@ import 'package:maibu_satabot_v2/core/consts/http_api_consts.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/data/datasources/device_http_datasource.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||
|
||||
import '../../../domain/entities/device_location_entity.dart';
|
||||
|
||||
class DeviceHttpDatasourceImpl implements DeviceHttpDatasource {
|
||||
final Dio dio;
|
||||
|
||||
@@ -80,13 +82,13 @@ class DeviceHttpDatasourceImpl implements DeviceHttpDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> getDeviceLocation(String username) async {
|
||||
Future<dynamic> getDeviceLocation(String deviceame) async {
|
||||
// TODO: implement getDeviceLocation
|
||||
try {
|
||||
// 发起 GET 请求
|
||||
final response = await dio.get(
|
||||
'https://serviceri.satabot.com/iot/device/userDevice',
|
||||
queryParameters: {'tenantName': username},
|
||||
queryParameters: {'tenantName': deviceame},
|
||||
// options: Options(
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
@@ -99,7 +101,14 @@ class DeviceHttpDatasourceImpl implements DeviceHttpDatasource {
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
if (data['code'] == 200) {
|
||||
return 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