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:
@@ -26,8 +26,11 @@ class WarehouseService {
|
||||
|
||||
return response.items.map((dto) => _convertDtoToWarehouseLocation(dto)).toList();
|
||||
} on ApiException catch (e) {
|
||||
print('[WarehouseService] ApiException: ${e.message}');
|
||||
throw ServerFailure(message: e.message);
|
||||
} catch (e) {
|
||||
} catch (e, stackTrace) {
|
||||
print('[WarehouseService] Error loading warehouse locations: $e');
|
||||
print('[WarehouseService] Stack trace: $stackTrace');
|
||||
throw ServerFailure(message: '창고 위치 목록을 불러오는 데 실패했습니다: $e');
|
||||
}
|
||||
}
|
||||
@@ -149,29 +152,30 @@ class WarehouseService {
|
||||
|
||||
// DTO를 Flutter 모델로 변환
|
||||
WarehouseLocation _convertDtoToWarehouseLocation(WarehouseLocationDto dto) {
|
||||
// 주소 조합
|
||||
final addressParts = <String>[];
|
||||
if (dto.address != null && dto.address!.isNotEmpty) {
|
||||
addressParts.add(dto.address!);
|
||||
}
|
||||
if (dto.city != null && dto.city!.isNotEmpty) {
|
||||
addressParts.add(dto.city!);
|
||||
}
|
||||
if (dto.state != null && dto.state!.isNotEmpty) {
|
||||
addressParts.add(dto.state!);
|
||||
}
|
||||
|
||||
// API에 주소 정보가 없으므로 기본값 사용
|
||||
final address = Address(
|
||||
zipCode: dto.postalCode ?? '',
|
||||
region: dto.city ?? '',
|
||||
detailAddress: addressParts.join(' '),
|
||||
detailAddress: dto.address ?? '주소 정보 없음',
|
||||
);
|
||||
|
||||
// 담당자 정보 조합
|
||||
final remarkParts = <String>[];
|
||||
if (dto.code != null) {
|
||||
remarkParts.add('코드: ${dto.code}');
|
||||
}
|
||||
if (dto.managerName != null) {
|
||||
remarkParts.add('담당자: ${dto.managerName}');
|
||||
}
|
||||
if (dto.managerPhone != null) {
|
||||
remarkParts.add('연락처: ${dto.managerPhone}');
|
||||
}
|
||||
|
||||
return WarehouseLocation(
|
||||
id: dto.id,
|
||||
name: dto.name,
|
||||
address: address,
|
||||
remark: dto.managerName != null ? '담당자: ${dto.managerName}' : null,
|
||||
remark: remarkParts.isNotEmpty ? remarkParts.join(', ') : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user