backup: 사용하지 않는 파일 삭제 전 복구 지점
- 전체 371개 파일 중 82개 미사용 파일 식별 - Phase 1: 33개 파일 삭제 예정 (100% 안전) - Phase 2: 30개 파일 삭제 검토 예정 - Phase 3: 19개 파일 수동 검토 예정 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../core/constants/app_constants.dart';
|
||||
import '../../../data/models/rent_dto.dart';
|
||||
import '../../../domain/usecases/rent_usecase.dart';
|
||||
|
||||
@@ -34,7 +35,7 @@ class RentController with ChangeNotifier {
|
||||
|
||||
// 페이징 관련 getter (UI 호환성)
|
||||
int get currentPage => 1; // 단순화된 페이징 구조
|
||||
int get totalPages => (_rents.length / 10).ceil();
|
||||
int get totalPages => (_rents.length / AppConstants.rentPageSize).ceil();
|
||||
int get totalItems => _rents.length;
|
||||
|
||||
|
||||
@@ -53,11 +54,15 @@ class RentController with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 임대 목록 조회
|
||||
/// 임대 목록 조회 (백엔드 실제 파라미터)
|
||||
Future<void> loadRents({
|
||||
int page = 1,
|
||||
int pageSize = 10,
|
||||
String? search,
|
||||
int perPage = AppConstants.rentPageSize,
|
||||
int? equipmentId,
|
||||
int? companyId,
|
||||
bool? isActive,
|
||||
DateTime? dateFrom,
|
||||
DateTime? dateTo,
|
||||
bool refresh = false,
|
||||
}) async {
|
||||
try {
|
||||
@@ -70,14 +75,16 @@ class RentController with ChangeNotifier {
|
||||
|
||||
final response = await _rentUseCase.getRents(
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
search: search,
|
||||
// status: _selectedStatus, // 삭제된 파라미터
|
||||
equipmentHistoryId: _selectedEquipmentHistoryId,
|
||||
perPage: perPage,
|
||||
equipmentId: equipmentId,
|
||||
companyId: companyId,
|
||||
isActive: isActive,
|
||||
dateFrom: dateFrom,
|
||||
dateTo: dateTo,
|
||||
);
|
||||
|
||||
// response를 List<RentDto>로 캐스팅
|
||||
_rents = response as List<RentDto>;
|
||||
// 올바른 RentListResponse.items 접근
|
||||
_rents = response.items;
|
||||
|
||||
clearError();
|
||||
} catch (e) {
|
||||
@@ -192,16 +199,36 @@ class RentController with ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
/// 상태 필터 설정
|
||||
void setStatusFilter(String? status) {
|
||||
_selectedStatus = status;
|
||||
notifyListeners();
|
||||
/// 진행중인 임대 조회 (백엔드 실존 API)
|
||||
Future<void> loadActiveRents() async {
|
||||
try {
|
||||
_setLoading(true);
|
||||
|
||||
final activeRents = await _rentUseCase.getActiveRents();
|
||||
_rents = activeRents;
|
||||
|
||||
clearError();
|
||||
} catch (e) {
|
||||
_setError('진행중인 임대를 불러오는데 실패했습니다: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// 장비 이력 필터 설정
|
||||
void setEquipmentHistoryFilter(int? equipmentHistoryId) {
|
||||
_selectedEquipmentHistoryId = equipmentHistoryId;
|
||||
notifyListeners();
|
||||
/// 장비별 임대 조회 (백엔드 필터링)
|
||||
Future<void> loadRentsByEquipment(int equipmentId) async {
|
||||
try {
|
||||
_setLoading(true);
|
||||
|
||||
final equipmentRents = await _rentUseCase.getRentsByEquipment(equipmentId);
|
||||
_rents = equipmentRents;
|
||||
|
||||
clearError();
|
||||
} catch (e) {
|
||||
_setError('장비별 임대를 불러오는데 실패했습니다: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// 필터 초기화
|
||||
@@ -210,6 +237,12 @@ class RentController with ChangeNotifier {
|
||||
_selectedEquipmentHistoryId = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 장비 이력 필터 설정 (UI 호환성)
|
||||
void setEquipmentHistoryFilter(int? equipmentHistoryId) {
|
||||
_selectedEquipmentHistoryId = equipmentHistoryId;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 선택된 임대 초기화
|
||||
void clearSelectedRent() {
|
||||
@@ -217,19 +250,28 @@ class RentController with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 간단한 기간 계산 (클라이언트 사이드)
|
||||
int calculateRentDays(DateTime startDate, DateTime endDate) {
|
||||
return endDate.difference(startDate).inDays;
|
||||
}
|
||||
|
||||
// 임대 상태 간단 판단
|
||||
// 백엔드 계산 필드 활용 (강력한 기능)
|
||||
String getRentStatus(RentDto rent) {
|
||||
// 백엔드에서 계산된 is_active 필드 활용
|
||||
if (rent.isActive == true) return '진행중';
|
||||
|
||||
// 날짜 기반 판단 (Fallback)
|
||||
final now = DateTime.now();
|
||||
if (rent.startedAt.isAfter(now)) return '예약';
|
||||
if (rent.endedAt.isBefore(now)) return '종료';
|
||||
return '진행중';
|
||||
}
|
||||
|
||||
// 백엔드에서 계산된 남은 일수 활용
|
||||
int getRemainingDays(RentDto rent) {
|
||||
return rent.daysRemaining ?? 0;
|
||||
}
|
||||
|
||||
// 백엔드에서 계산된 총 일수 활용
|
||||
int getTotalDays(RentDto rent) {
|
||||
return rent.totalDays ?? 0;
|
||||
}
|
||||
|
||||
// UI 호환성을 위한 상태 표시명
|
||||
String getRentStatusDisplayName(String status) {
|
||||
switch (status.toLowerCase()) {
|
||||
@@ -252,13 +294,24 @@ class RentController with ChangeNotifier {
|
||||
await loadRents(refresh: true);
|
||||
}
|
||||
|
||||
/// 임대 반납 처리 (endedAt를 현재 시간으로 수정)
|
||||
/// 임대 반납 처리 (백엔드 PUT API 활용)
|
||||
Future<bool> returnRent(int id) async {
|
||||
return await updateRent(
|
||||
id: id,
|
||||
endedAt: DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
/// 상태 필터 설정 (UI 호환성)
|
||||
void setStatusFilter(String? status) {
|
||||
_selectedStatus = status;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 임대 기간 계산 (UI 호환성)
|
||||
int calculateRentDays(DateTime startDate, DateTime endDate) {
|
||||
return endDate.difference(startDate).inDays;
|
||||
}
|
||||
|
||||
/// 임대 총 비용 계산 (문자열 날짜 기반)
|
||||
double calculateTotalRent(String startDate, String endDate, double dailyRate) {
|
||||
|
||||
Reference in New Issue
Block a user