fix: API 응답 파싱 오류 수정 및 에러 처리 개선

주요 변경사항:
- 창고 관리 API 응답 구조와 DTO 불일치 수정
  - WarehouseLocationDto에 code, manager_phone 필드 추가
  - RemoteDataSource에서 API 응답을 DTO 구조에 맞게 변환
- 회사 관리 API 응답 파싱 오류 수정
  - CompanyResponse의 필수 필드를 nullable로 변경
  - PaginatedResponse 구조 매핑 로직 개선
- 에러 처리 및 로깅 개선
  - Service Layer에 상세 에러 로깅 추가
  - Controller에서 에러 타입별 처리
- 새로운 유틸리티 추가
  - ResponseInterceptor: API 응답 정규화
  - DebugLogger: 디버깅 도구
  - HealthCheckService: 서버 상태 확인
- 문서화
  - API 통합 테스트 가이드
  - 에러 분석 보고서
  - 리팩토링 계획서
This commit is contained in:
JiWoong Sul
2025-07-31 19:15:39 +09:00
parent ad2c699ff7
commit f08b7fec79
89 changed files with 10521 additions and 892 deletions

View File

@@ -51,7 +51,25 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
queryParameters: queryParams,
);
return WarehouseLocationListDto.fromJson(response.data);
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
// API 응답 구조를 DTO에 맞게 변환
final List<dynamic> dataList = response.data['data'];
final pagination = response.data['pagination'] ?? {};
final listData = {
'items': dataList,
'total': pagination['total'] ?? 0,
'page': pagination['page'] ?? 1,
'per_page': pagination['per_page'] ?? 20,
'total_pages': pagination['total_pages'] ?? 1,
};
return WarehouseLocationListDto.fromJson(listData);
} else {
throw ApiException(
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse locations',
);
}
} catch (e) {
throw _handleError(e);
}
@@ -64,7 +82,13 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
'${ApiEndpoints.warehouseLocations}/$id',
);
return WarehouseLocationDto.fromJson(response.data);
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
return WarehouseLocationDto.fromJson(response.data['data']);
} else {
throw ApiException(
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse location',
);
}
} catch (e) {
throw _handleError(e);
}
@@ -78,7 +102,13 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
data: request.toJson(),
);
return WarehouseLocationDto.fromJson(response.data);
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
return WarehouseLocationDto.fromJson(response.data['data']);
} else {
throw ApiException(
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse location',
);
}
} catch (e) {
throw _handleError(e);
}
@@ -92,7 +122,13 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
data: request.toJson(),
);
return WarehouseLocationDto.fromJson(response.data);
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
return WarehouseLocationDto.fromJson(response.data['data']);
} else {
throw ApiException(
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse location',
);
}
} catch (e) {
throw _handleError(e);
}
@@ -126,7 +162,13 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
queryParameters: queryParams,
);
return WarehouseEquipmentListDto.fromJson(response.data);
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
return WarehouseEquipmentListDto.fromJson(response.data['data']);
} else {
throw ApiException(
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse equipment',
);
}
} catch (e) {
throw _handleError(e);
}
@@ -139,7 +181,13 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
'${ApiEndpoints.warehouseLocations}/$id/capacity',
);
return WarehouseCapacityInfo.fromJson(response.data);
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
return WarehouseCapacityInfo.fromJson(response.data['data']);
} else {
throw ApiException(
message: response.data?['error']?['message'] ?? 'Failed to fetch warehouse capacity',
);
}
} catch (e) {
throw _handleError(e);
}
@@ -152,8 +200,8 @@ class WarehouseRemoteDataSourceImpl implements WarehouseRemoteDataSource {
'${ApiEndpoints.warehouseLocations}/in-use',
);
if (response.data is List) {
return (response.data as List)
if (response.data != null && response.data['success'] == true && response.data['data'] is List) {
return (response.data['data'] as List)
.map((item) => WarehouseLocationDto.fromJson(item))
.toList();
} else {