feat: 대시보드에 라이선스 만료 요약 및 Lookup 데이터 캐싱 시스템 구현
- License Expiry Summary API 연동 완료 - 30/60/90일 내 만료 예정 라이선스 요약 표시 - 대시보드 상단에 알림 카드로 통합 - 만료 임박 순서로 색상 구분 (빨강/주황/노랑) - Lookup 데이터 전역 캐싱 시스템 구축 - LookupService 및 RemoteDataSource 생성 - 전체 lookup 데이터 일괄 로드 및 캐싱 - 타입별 필터링 지원 - 새로운 모델 추가 - LicenseExpirySummary (Freezed) - LookupData, LookupCategory, LookupItem 모델 - CLAUDE.md 문서 업데이트 - 미사용 API 활용 계획 추가 - 구현 우선순위 정의 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/data/models/dashboard/equipment_status_distribution.dart';
|
||||
import 'package:superport/data/models/dashboard/expiring_license.dart';
|
||||
import 'package:superport/data/models/dashboard/license_expiry_summary.dart';
|
||||
import 'package:superport/data/models/dashboard/overview_stats.dart';
|
||||
import 'package:superport/data/models/dashboard/recent_activity.dart';
|
||||
import 'package:superport/services/dashboard_service.dart';
|
||||
@@ -17,35 +18,53 @@ class OverviewController extends ChangeNotifier {
|
||||
List<RecentActivity> _recentActivities = [];
|
||||
EquipmentStatusDistribution? _equipmentStatus;
|
||||
List<ExpiringLicense> _expiringLicenses = [];
|
||||
LicenseExpirySummary? _licenseExpirySummary;
|
||||
|
||||
// 로딩 상태
|
||||
bool _isLoadingStats = false;
|
||||
bool _isLoadingActivities = false;
|
||||
bool _isLoadingEquipmentStatus = false;
|
||||
bool _isLoadingLicenses = false;
|
||||
bool _isLoadingLicenseExpiry = false;
|
||||
|
||||
// 에러 상태
|
||||
String? _statsError;
|
||||
String? _activitiesError;
|
||||
String? _equipmentStatusError;
|
||||
String? _licensesError;
|
||||
String? _licenseExpiryError;
|
||||
|
||||
// Getters
|
||||
OverviewStats? get overviewStats => _overviewStats;
|
||||
List<RecentActivity> get recentActivities => _recentActivities;
|
||||
EquipmentStatusDistribution? get equipmentStatus => _equipmentStatus;
|
||||
List<ExpiringLicense> get expiringLicenses => _expiringLicenses;
|
||||
LicenseExpirySummary? get licenseExpirySummary => _licenseExpirySummary;
|
||||
|
||||
// 추가 getter
|
||||
int get totalCompanies => _overviewStats?.totalCompanies ?? 0;
|
||||
int get totalUsers => _overviewStats?.totalUsers ?? 0;
|
||||
|
||||
bool get isLoading => _isLoadingStats || _isLoadingActivities ||
|
||||
_isLoadingEquipmentStatus || _isLoadingLicenses;
|
||||
_isLoadingEquipmentStatus || _isLoadingLicenses ||
|
||||
_isLoadingLicenseExpiry;
|
||||
|
||||
String? get error {
|
||||
return _statsError ?? _activitiesError ??
|
||||
_equipmentStatusError ?? _licensesError;
|
||||
_equipmentStatusError ?? _licensesError ?? _licenseExpiryError;
|
||||
}
|
||||
|
||||
// 라이선스 만료 알림 여부
|
||||
bool get hasExpiringLicenses {
|
||||
if (_licenseExpirySummary == null) return false;
|
||||
return (_licenseExpirySummary!.within30Days > 0 ||
|
||||
_licenseExpirySummary!.expired > 0);
|
||||
}
|
||||
|
||||
// 긴급 라이선스 수 (30일 이내 또는 만료)
|
||||
int get urgentLicenseCount {
|
||||
if (_licenseExpirySummary == null) return 0;
|
||||
return _licenseExpirySummary!.within30Days + _licenseExpirySummary!.expired;
|
||||
}
|
||||
|
||||
OverviewController();
|
||||
@@ -58,6 +77,7 @@ class OverviewController extends ChangeNotifier {
|
||||
_loadRecentActivities(),
|
||||
_loadEquipmentStatus(),
|
||||
_loadExpiringLicenses(),
|
||||
_loadLicenseExpirySummary(),
|
||||
], eagerError: false); // 하나의 작업이 실패해도 다른 작업 계속 진행
|
||||
} catch (e) {
|
||||
DebugLogger.logError('대시보드 데이터 로드 중 오류', error: e);
|
||||
@@ -233,6 +253,38 @@ class OverviewController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _loadLicenseExpirySummary() async {
|
||||
_isLoadingLicenseExpiry = true;
|
||||
_licenseExpiryError = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final result = await _dashboardService.getLicenseExpirySummary();
|
||||
|
||||
result.fold(
|
||||
(failure) {
|
||||
_licenseExpiryError = failure.message;
|
||||
DebugLogger.logError('라이선스 만료 요약 로드 실패', error: failure.message);
|
||||
},
|
||||
(summary) {
|
||||
_licenseExpirySummary = summary;
|
||||
DebugLogger.log('라이선스 만료 요약 로드 성공', tag: 'DASHBOARD', data: {
|
||||
'within30Days': summary.within30Days,
|
||||
'within60Days': summary.within60Days,
|
||||
'within90Days': summary.within90Days,
|
||||
'expired': summary.expired,
|
||||
});
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
_licenseExpiryError = '라이선스 만료 요약을 불러올 수 없습니다';
|
||||
DebugLogger.logError('라이선스 만료 요약 로드 예외', error: e);
|
||||
}
|
||||
|
||||
_isLoadingLicenseExpiry = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 활동 타입별 아이콘과 색상 가져오기
|
||||
IconData getActivityIcon(String activityType) {
|
||||
switch (activityType.toLowerCase()) {
|
||||
|
||||
Reference in New Issue
Block a user