refactor: 프로젝트 구조 개선 및 테스트 시스템 강화
주요 변경사항: - CLAUDE.md: 프로젝트 규칙 v2.0으로 업데이트, 아키텍처 명확화 - 불필요한 문서 제거: NEXT_TASKS.md, TEST_PROGRESS.md, test_results 파일들 - 테스트 시스템 개선: 실제 API 테스트 스위트 추가 (15개 새 테스트 파일) - License 관리: DTO 모델 개선, API 응답 처리 최적화 - 에러 처리: Interceptor 로직 강화, 상세 로깅 추가 - Company/User/Warehouse 테스트: 자동화 테스트 안정성 향상 - Phone Utils: 전화번호 포맷팅 로직 개선 - Overview Controller: 대시보드 데이터 로딩 최적화 - Analysis Options: Flutter 린트 규칙 추가 테스트 개선: - company_real_api_test.dart: 실제 API 회사 관리 테스트 - equipment_in/out_real_api_test.dart: 장비 입출고 API 테스트 - license_real_api_test.dart: 라이선스 관리 API 테스트 - user_real_api_test.dart: 사용자 관리 API 테스트 - warehouse_location_real_api_test.dart: 창고 위치 API 테스트 - filter_sort_test.dart: 필터링/정렬 기능 테스트 - pagination_test.dart: 페이지네이션 테스트 - interactive_search_test.dart: 검색 기능 테스트 - overview_dashboard_test.dart: 대시보드 통합 테스트 코드 품질: - 모든 서비스에 에러 처리 강화 - DTO 모델 null safety 개선 - 테스트 커버리지 확대 - 불필요한 로그 파일 제거로 리포지토리 정리 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:superport/core/constants/api_endpoints.dart';
|
||||
import 'package:superport/core/errors/exceptions.dart';
|
||||
@@ -63,7 +64,53 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
|
||||
);
|
||||
|
||||
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
||||
return LicenseListResponseDto.fromJson(response.data['data']);
|
||||
// API 응답이 배열인 경우와 객체인 경우를 모두 처리
|
||||
final data = response.data['data'];
|
||||
if (data is List) {
|
||||
// 배열 응답을 LicenseListResponseDto 형식으로 변환
|
||||
final List<LicenseDto> licenses = [];
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
try {
|
||||
final item = data[i];
|
||||
debugPrint('📑 Parsing license item $i: ${item['license_key']}');
|
||||
|
||||
// null 검사 및 기본값 설정
|
||||
final licenseDto = LicenseDto.fromJson({
|
||||
...item,
|
||||
// 필수 필드 보장
|
||||
'license_key': item['license_key'] ?? '',
|
||||
'is_active': item['is_active'] ?? true,
|
||||
'created_at': item['created_at'] ?? DateTime.now().toIso8601String(),
|
||||
'updated_at': item['updated_at'] ?? DateTime.now().toIso8601String(),
|
||||
});
|
||||
licenses.add(licenseDto);
|
||||
} catch (e, stackTrace) {
|
||||
debugPrint('❌ Error parsing license item $i: $e');
|
||||
debugPrint('Item data: ${data[i]}');
|
||||
debugPrint('Stack trace: $stackTrace');
|
||||
// 파싱 실패한 항목은 건너뛰고 계속
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final pagination = response.data['pagination'] ?? {};
|
||||
return LicenseListResponseDto(
|
||||
items: licenses,
|
||||
total: pagination['total'] ?? licenses.length,
|
||||
page: pagination['page'] ?? page,
|
||||
perPage: pagination['per_page'] ?? perPage,
|
||||
totalPages: pagination['total_pages'] ?? 1,
|
||||
);
|
||||
} else if (data['items'] != null) {
|
||||
// 이미 LicenseListResponseDto 형식인 경우
|
||||
return LicenseListResponseDto.fromJson(data);
|
||||
} else {
|
||||
// 예상치 못한 형식인 경우
|
||||
throw ApiException(
|
||||
message: 'Unexpected response format for license list',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw ApiException(
|
||||
message: response.data?['error']?['message'] ?? 'Failed to fetch licenses',
|
||||
@@ -202,7 +249,35 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource {
|
||||
);
|
||||
|
||||
if (response.data != null && response.data['success'] == true && response.data['data'] != null) {
|
||||
return ExpiringLicenseListDto.fromJson(response.data['data']);
|
||||
// API 응답이 배열 형태인 경우 처리
|
||||
final data = response.data['data'];
|
||||
final pagination = response.data['pagination'] ?? {};
|
||||
|
||||
if (data is List) {
|
||||
// 배열 응답을 ExpiringLicenseListDto 형식으로 변환
|
||||
final List<ExpiringLicenseDto> licenses = [];
|
||||
|
||||
for (var item in data) {
|
||||
try {
|
||||
licenses.add(ExpiringLicenseDto.fromJson(item));
|
||||
} catch (e) {
|
||||
debugPrint('❌ Error parsing expiring license: $e');
|
||||
debugPrint('Item data: $item');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return ExpiringLicenseListDto(
|
||||
items: licenses,
|
||||
total: pagination['total'] ?? licenses.length,
|
||||
page: pagination['page'] ?? page,
|
||||
perPage: pagination['per_page'] ?? perPage,
|
||||
totalPages: pagination['total_pages'] ?? 1,
|
||||
);
|
||||
} else {
|
||||
// 이미 올바른 형식인 경우
|
||||
return ExpiringLicenseListDto.fromJson(data);
|
||||
}
|
||||
} else {
|
||||
throw ApiException(
|
||||
message: response.data?['error']?['message'] ?? 'Failed to fetch expiring licenses',
|
||||
|
||||
Reference in New Issue
Block a user