feat: 장비 관리 기능 강화 및 이력 추적 개선
- EquipmentHistoryDto 모델 확장 (상세 정보 추가) - 장비 이력 화면 UI/UX 개선 - 장비 입고 폼 검증 로직 강화 - 테스트 이력 화면 추가 - API 응답 처리 개선 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -224,18 +224,73 @@ class EquipmentRemoteDataSourceImpl implements EquipmentRemoteDataSource {
|
||||
'per_page': perPage,
|
||||
};
|
||||
|
||||
print('[API] Requesting equipment history: ${ApiEndpoints.equipment}/$equipmentId/history');
|
||||
print('[API] Query params: $queryParams');
|
||||
|
||||
final response = await _apiClient.get(
|
||||
'${ApiEndpoints.equipment}/$equipmentId/history',
|
||||
queryParameters: queryParams,
|
||||
);
|
||||
|
||||
if (response.data['success'] == true && response.data['data'] != null) {
|
||||
final List<dynamic> data = response.data['data'];
|
||||
return data.map((json) => EquipmentHistoryDto.fromJson(json)).toList();
|
||||
print('[API] Response status: ${response.statusCode}');
|
||||
print('[API] Response data type: ${response.data.runtimeType}');
|
||||
print('[API] Full response: ${response.data}');
|
||||
|
||||
// API 응답 구조 확인
|
||||
if (response.data == null) {
|
||||
print('[API ERROR] Response data is null');
|
||||
throw ServerException(message: 'Empty response from server');
|
||||
}
|
||||
|
||||
// 응답이 Map인지 확인
|
||||
if (response.data is! Map) {
|
||||
print('[API ERROR] Response is not a Map: ${response.data.runtimeType}');
|
||||
throw ServerException(message: 'Invalid response format');
|
||||
}
|
||||
|
||||
// success 필드 확인
|
||||
final success = response.data['success'];
|
||||
print('[API] Success field: $success');
|
||||
|
||||
if (success == true) {
|
||||
final responseData = response.data['data'];
|
||||
print('[API] Data field type: ${responseData?.runtimeType}');
|
||||
|
||||
if (responseData == null) {
|
||||
print('[API] No data field, returning empty list');
|
||||
return [];
|
||||
}
|
||||
|
||||
if (responseData is! List) {
|
||||
print('[API ERROR] Data is not a List: ${responseData.runtimeType}');
|
||||
throw ServerException(message: 'Invalid data format');
|
||||
}
|
||||
|
||||
final List<dynamic> data = responseData;
|
||||
print('[API] History data count: ${data.length}');
|
||||
|
||||
if (data.isEmpty) {
|
||||
print('[API] Empty history data');
|
||||
return [];
|
||||
}
|
||||
|
||||
print('[API] First history item: ${data.first}');
|
||||
|
||||
try {
|
||||
final histories = data.map((json) {
|
||||
print('[API] Parsing history item: $json');
|
||||
return EquipmentHistoryDto.fromJson(json);
|
||||
}).toList();
|
||||
print('[API] Successfully parsed ${histories.length} history items');
|
||||
return histories;
|
||||
} catch (e) {
|
||||
print('[API ERROR] Failed to parse history data: $e');
|
||||
throw ServerException(message: 'Failed to parse history data: $e');
|
||||
}
|
||||
} else {
|
||||
throw ServerException(
|
||||
message: response.data['message'] ?? 'Failed to fetch equipment history',
|
||||
);
|
||||
final errorMessage = response.data['message'] ?? response.data['error'] ?? 'Failed to fetch equipment history';
|
||||
print('[API ERROR] Request failed: $errorMessage');
|
||||
throw ServerException(message: errorMessage);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw ServerException(
|
||||
|
||||
Reference in New Issue
Block a user