空洞逻辑
This commit is contained in:
@@ -15,6 +15,33 @@ class PathHttpDatasourceImpl implements PathHttpDatasource {
|
||||
|
||||
@override
|
||||
Future<List<DeviceAddPathPointModel>> generatePathRaw({required Map<String, dynamic> body}) async {
|
||||
try {
|
||||
// 1. 先打印基础信息
|
||||
print('=== 最终发送给后端的请求体 ===');
|
||||
print('请求体类型:${body.runtimeType}');
|
||||
print('是否包含holes:${body.containsKey('holes')}, holes长度:${(body['holes'] as List).length}');
|
||||
|
||||
// 2. 格式化打印JSON(带缩进,清晰展示嵌套结构)
|
||||
final jsonString = const JsonEncoder.withIndent(' ').convert(body);
|
||||
print('完整JSON请求体:\n$jsonString');
|
||||
|
||||
// 3. 可选:单独打印holes的JSON(重点关注)
|
||||
final holesJson = body['holes'] as List;
|
||||
print('=== 单独打印holes的JSON ===');
|
||||
if (holesJson.isEmpty) {
|
||||
print('holes 为空数组');
|
||||
} else {
|
||||
for (int i = 0; i < holesJson.length; i++) {
|
||||
print('第${i + 1}组hole:\n${const JsonEncoder.withIndent(' ').convert(holesJson[i])}');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 防止JSON序列化失败导致崩溃
|
||||
print('打印请求体失败:$e');
|
||||
// 降级打印原始body(虽然格式乱,但能看基础数据)
|
||||
print('原始body数据:$body');
|
||||
}
|
||||
|
||||
final token = (await _userStorage.getUser())?.token;
|
||||
if (token == null) throw Exception('Token missing');
|
||||
|
||||
@@ -23,7 +50,6 @@ class PathHttpDatasourceImpl implements PathHttpDatasource {
|
||||
headers: {'Content-Type': 'application/json', 'Authorization': token},
|
||||
body: jsonEncode(body),
|
||||
);
|
||||
//debugPrint('请求体: ${jsonEncode(body)}');
|
||||
|
||||
// 🔥 完整打印响应体
|
||||
//printFullString(formatJson(jsonEncode(response.body)));
|
||||
|
||||
Reference in New Issue
Block a user