## 주요 변경사항 ### 아키텍처 개선 - Clean Architecture 패턴 적용 (Domain, Data, Presentation 레이어 분리) - Use Case 패턴 도입으로 비즈니스 로직 캡슐화 - Repository 패턴으로 데이터 접근 추상화 - 의존성 주입 구조 개선 ### 상태 관리 최적화 - 모든 Controller에서 불필요한 상태 관리 로직 제거 - 페이지네이션 로직 통일 및 간소화 - 에러 처리 로직 개선 (에러 메시지 한글화) - 로딩 상태 관리 최적화 ### Mock 서비스 제거 - MockDataService 완전 제거 - 모든 화면을 실제 API 전용으로 전환 - 불필요한 Mock 관련 코드 정리 ### UI/UX 개선 - Overview 화면 대시보드 기능 강화 - 라이선스 만료 알림 위젯 추가 - 사이드바 네비게이션 개선 - 일관된 UI 컴포넌트 사용 ### 코드 품질 - 중복 코드 제거 및 함수 추출 - 파일별 책임 분리 명확화 - 테스트 코드 업데이트 ## 영향 범위 - 모든 화면의 Controller 리팩토링 - API 통신 레이어 구조 개선 - 에러 처리 및 로깅 시스템 개선 ## 향후 계획 - 단위 테스트 커버리지 확대 - 통합 테스트 시나리오 추가 - 성능 모니터링 도구 통합
75 lines
2.4 KiB
Dart
75 lines
2.4 KiB
Dart
import 'package:dartz/dartz.dart';
|
|
import 'package:injectable/injectable.dart';
|
|
import '../../../data/models/license/license_dto.dart';
|
|
import '../../../data/repositories/license_repository.dart';
|
|
import '../../../core/errors/failures.dart';
|
|
import '../base_usecase.dart';
|
|
|
|
/// 라이선스 수정 UseCase
|
|
@injectable
|
|
class UpdateLicenseUseCase implements UseCase<LicenseDto, UpdateLicenseParams> {
|
|
final LicenseRepository repository;
|
|
|
|
UpdateLicenseUseCase(this.repository);
|
|
|
|
@override
|
|
Future<Either<Failure, LicenseDto>> call(UpdateLicenseParams params) async {
|
|
try {
|
|
// 비즈니스 로직: 만료일 검증
|
|
if (params.expiryDate != null && params.startDate != null) {
|
|
if (params.expiryDate!.isBefore(params.startDate!)) {
|
|
return Left(ValidationFailure(message: '만료일은 시작일 이후여야 합니다'));
|
|
}
|
|
|
|
// 비즈니스 로직: 최소 라이선스 기간 검증 (30일)
|
|
final duration = params.expiryDate!.difference(params.startDate!).inDays;
|
|
if (duration < 30) {
|
|
return Left(ValidationFailure(message: '라이선스 기간은 최소 30일 이상이어야 합니다'));
|
|
}
|
|
}
|
|
|
|
final license = await repository.updateLicense(params.id, params.toMap());
|
|
return Right(license);
|
|
} catch (e) {
|
|
return Left(ServerFailure(message: e.toString()));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 라이선스 수정 파라미터
|
|
class UpdateLicenseParams {
|
|
final int id;
|
|
final int? equipmentId;
|
|
final int? companyId;
|
|
final String? licenseType;
|
|
final DateTime? startDate;
|
|
final DateTime? expiryDate;
|
|
final String? description;
|
|
final double? cost;
|
|
final String? status;
|
|
|
|
UpdateLicenseParams({
|
|
required this.id,
|
|
this.equipmentId,
|
|
this.companyId,
|
|
this.licenseType,
|
|
this.startDate,
|
|
this.expiryDate,
|
|
this.description,
|
|
this.cost,
|
|
this.status,
|
|
});
|
|
|
|
Map<String, dynamic> toMap() {
|
|
final Map<String, dynamic> data = {};
|
|
if (equipmentId != null) data['equipment_id'] = equipmentId;
|
|
if (companyId != null) data['company_id'] = companyId;
|
|
if (licenseType != null) data['license_type'] = licenseType;
|
|
if (startDate != null) data['start_date'] = startDate!.toIso8601String();
|
|
if (expiryDate != null) data['expiry_date'] = expiryDate!.toIso8601String();
|
|
if (description != null) data['description'] = description;
|
|
if (cost != null) data['cost'] = cost;
|
|
if (status != null) data['status'] = status;
|
|
return data;
|
|
}
|
|
} |