주요 변경사항: - 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>
122 lines
4.6 KiB
Dart
122 lines
4.6 KiB
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'license_dto.freezed.dart';
|
|
part 'license_dto.g.dart';
|
|
|
|
// 날짜를 YYYY-MM-DD 형식으로 변환하는 헬퍼 함수
|
|
String? _dateToJson(DateTime? date) {
|
|
if (date == null) return null;
|
|
return '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
|
}
|
|
|
|
// YYYY-MM-DD 형식 문자열을 DateTime으로 변환하는 헬퍼 함수
|
|
DateTime? _dateFromJson(String? dateStr) {
|
|
if (dateStr == null || dateStr.isEmpty) return null;
|
|
try {
|
|
// YYYY-MM-DD 형식 파싱
|
|
if (dateStr.contains('-') && dateStr.length == 10) {
|
|
final parts = dateStr.split('-');
|
|
return DateTime(int.parse(parts[0]), int.parse(parts[1]), int.parse(parts[2]));
|
|
}
|
|
// ISO 8601 형식도 지원
|
|
return DateTime.parse(dateStr);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// 필수 날짜 필드용 헬퍼 함수 (항상 non-null DateTime 반환)
|
|
DateTime _requiredDateFromJson(String? dateStr) {
|
|
if (dateStr == null || dateStr.isEmpty) return DateTime.now();
|
|
try {
|
|
// YYYY-MM-DD 형식 파싱
|
|
if (dateStr.contains('-') && dateStr.length == 10) {
|
|
final parts = dateStr.split('-');
|
|
return DateTime(int.parse(parts[0]), int.parse(parts[1]), int.parse(parts[2]));
|
|
}
|
|
// ISO 8601 형식도 지원
|
|
return DateTime.parse(dateStr);
|
|
} catch (e) {
|
|
return DateTime.now();
|
|
}
|
|
}
|
|
|
|
/// 라이선스 전체 정보 DTO
|
|
@freezed
|
|
class LicenseDto with _$LicenseDto {
|
|
const factory LicenseDto({
|
|
required int id,
|
|
@JsonKey(name: 'license_key') required String licenseKey,
|
|
@JsonKey(name: 'product_name') String? productName,
|
|
String? vendor,
|
|
@JsonKey(name: 'license_type') String? licenseType,
|
|
@JsonKey(name: 'user_count') int? userCount,
|
|
@JsonKey(name: 'purchase_date', toJson: _dateToJson, fromJson: _dateFromJson) DateTime? purchaseDate,
|
|
@JsonKey(name: 'expiry_date', toJson: _dateToJson, fromJson: _dateFromJson) DateTime? expiryDate,
|
|
@JsonKey(name: 'purchase_price') double? purchasePrice,
|
|
@JsonKey(name: 'company_id') int? companyId,
|
|
@JsonKey(name: 'branch_id') int? branchId,
|
|
@JsonKey(name: 'assigned_user_id') int? assignedUserId,
|
|
String? remark,
|
|
@JsonKey(name: 'is_active') required bool isActive,
|
|
@JsonKey(name: 'created_at') required DateTime createdAt,
|
|
@JsonKey(name: 'updated_at') required DateTime updatedAt,
|
|
// 추가 필드 (조인된 데이터)
|
|
@JsonKey(name: 'company_name') String? companyName,
|
|
@JsonKey(name: 'branch_name') String? branchName,
|
|
@JsonKey(name: 'assigned_user_name') String? assignedUserName,
|
|
}) = _LicenseDto;
|
|
|
|
factory LicenseDto.fromJson(Map<String, dynamic> json) => _$LicenseDtoFromJson(json);
|
|
}
|
|
|
|
/// 라이선스 목록 응답 DTO
|
|
@freezed
|
|
class LicenseListResponseDto with _$LicenseListResponseDto {
|
|
const factory LicenseListResponseDto({
|
|
required List<LicenseDto> items,
|
|
required int total,
|
|
required int page,
|
|
@JsonKey(name: 'per_page') required int perPage,
|
|
@JsonKey(name: 'total_pages') required int totalPages,
|
|
}) = _LicenseListResponseDto;
|
|
|
|
factory LicenseListResponseDto.fromJson(Map<String, dynamic> json) =>
|
|
_$LicenseListResponseDtoFromJson(json);
|
|
}
|
|
|
|
/// 만료 예정 라이선스 DTO
|
|
@freezed
|
|
class ExpiringLicenseDto with _$ExpiringLicenseDto {
|
|
const factory ExpiringLicenseDto({
|
|
required int id,
|
|
@JsonKey(name: 'license_key') required String licenseKey,
|
|
@JsonKey(name: 'product_name') String? productName,
|
|
String? vendor,
|
|
@JsonKey(name: 'expiry_date', fromJson: _requiredDateFromJson) required DateTime expiryDate,
|
|
@JsonKey(name: 'days_until_expiry') required int daysUntilExpiry,
|
|
@JsonKey(name: 'assigned_user_id') int? assignedUserId,
|
|
@JsonKey(name: 'company_id') int? companyId,
|
|
@JsonKey(name: 'company_name') String? companyName,
|
|
@JsonKey(name: 'assigned_user_name') String? assignedUserName,
|
|
@JsonKey(name: 'is_active', defaultValue: true) bool? isActive,
|
|
}) = _ExpiringLicenseDto;
|
|
|
|
factory ExpiringLicenseDto.fromJson(Map<String, dynamic> json) =>
|
|
_$ExpiringLicenseDtoFromJson(json);
|
|
}
|
|
|
|
/// 만료 예정 라이선스 목록 응답 DTO
|
|
@freezed
|
|
class ExpiringLicenseListDto with _$ExpiringLicenseListDto {
|
|
const factory ExpiringLicenseListDto({
|
|
required List<ExpiringLicenseDto> items,
|
|
required int total,
|
|
required int page,
|
|
@JsonKey(name: 'per_page') required int perPage,
|
|
@JsonKey(name: 'total_pages') required int totalPages,
|
|
}) = _ExpiringLicenseListDto;
|
|
|
|
factory ExpiringLicenseListDto.fromJson(Map<String, dynamic> json) =>
|
|
_$ExpiringLicenseListDtoFromJson(json);
|
|
} |