## 주요 변경사항 ### 아키텍처 개선 - Clean Architecture 패턴 적용 (Domain, Data, Presentation 레이어 분리) - Use Case 패턴 도입으로 비즈니스 로직 캡슐화 - Repository 패턴으로 데이터 접근 추상화 - 의존성 주입 구조 개선 ### 상태 관리 최적화 - 모든 Controller에서 불필요한 상태 관리 로직 제거 - 페이지네이션 로직 통일 및 간소화 - 에러 처리 로직 개선 (에러 메시지 한글화) - 로딩 상태 관리 최적화 ### Mock 서비스 제거 - MockDataService 완전 제거 - 모든 화면을 실제 API 전용으로 전환 - 불필요한 Mock 관련 코드 정리 ### UI/UX 개선 - Overview 화면 대시보드 기능 강화 - 라이선스 만료 알림 위젯 추가 - 사이드바 네비게이션 개선 - 일관된 UI 컴포넌트 사용 ### 코드 품질 - 중복 코드 제거 및 함수 추출 - 파일별 책임 분리 명확화 - 테스트 코드 업데이트 ## 영향 범위 - 모든 화면의 Controller 리팩토링 - API 통신 레이어 구조 개선 - 에러 처리 및 로깅 시스템 개선 ## 향후 계획 - 단위 테스트 커버리지 확대 - 통합 테스트 시나리오 추가 - 성능 모니터링 도구 통합
85 lines
2.5 KiB
Dart
85 lines
2.5 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 CheckLicenseExpiryUseCase implements UseCase<LicenseExpiryResult, CheckLicenseExpiryParams> {
|
|
final LicenseRepository repository;
|
|
|
|
CheckLicenseExpiryUseCase(this.repository);
|
|
|
|
@override
|
|
Future<Either<Failure, LicenseExpiryResult>> call(CheckLicenseExpiryParams params) async {
|
|
try {
|
|
// 모든 라이선스 조회
|
|
final allLicenses = await repository.getLicenses(
|
|
page: 1,
|
|
perPage: 10000, // 모든 라이선스 조회
|
|
);
|
|
|
|
final now = DateTime.now();
|
|
final expiring30Days = <LicenseDto>[];
|
|
final expiring60Days = <LicenseDto>[];
|
|
final expiring90Days = <LicenseDto>[];
|
|
final expired = <LicenseDto>[];
|
|
|
|
for (final license in allLicenses.items) {
|
|
if (license.expiryDate == null) continue;
|
|
|
|
final daysUntilExpiry = license.expiryDate!.difference(now).inDays;
|
|
|
|
if (daysUntilExpiry < 0) {
|
|
expired.add(license);
|
|
} else if (daysUntilExpiry <= 30) {
|
|
expiring30Days.add(license);
|
|
} else if (daysUntilExpiry <= 60) {
|
|
expiring60Days.add(license);
|
|
} else if (daysUntilExpiry <= 90) {
|
|
expiring90Days.add(license);
|
|
}
|
|
}
|
|
|
|
return Right(LicenseExpiryResult(
|
|
expiring30Days: expiring30Days,
|
|
expiring60Days: expiring60Days,
|
|
expiring90Days: expiring90Days,
|
|
expired: expired,
|
|
));
|
|
} catch (e) {
|
|
return Left(ServerFailure(message: e.toString()));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 라이선스 만료일 체크 파라미터
|
|
class CheckLicenseExpiryParams {
|
|
final int? companyId;
|
|
final String? equipmentType;
|
|
|
|
CheckLicenseExpiryParams({
|
|
this.companyId,
|
|
this.equipmentType,
|
|
});
|
|
}
|
|
|
|
/// 라이선스 만료일 체크 결과
|
|
class LicenseExpiryResult {
|
|
final List<LicenseDto> expiring30Days;
|
|
final List<LicenseDto> expiring60Days;
|
|
final List<LicenseDto> expiring90Days;
|
|
final List<LicenseDto> expired;
|
|
|
|
LicenseExpiryResult({
|
|
required this.expiring30Days,
|
|
required this.expiring60Days,
|
|
required this.expiring90Days,
|
|
required this.expired,
|
|
});
|
|
|
|
int get totalExpiring => expiring30Days.length + expiring60Days.length + expiring90Days.length;
|
|
int get totalExpired => expired.length;
|
|
} |