refactor: Repository 패턴 적용 및 Clean Architecture 완성
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled

## 주요 변경사항

### 🏗️ Architecture
- Repository 패턴 전면 도입 (인터페이스/구현체 분리)
- Domain Layer에 Repository 인터페이스 정의
- Data Layer에 Repository 구현체 배치
- UseCase 의존성을 Service에서 Repository로 전환

### 📦 Dependency Injection
- GetIt 기반 DI Container 재구성 (lib/injection_container.dart)
- Repository 인터페이스와 구현체 등록
- Service와 Repository 공존 (마이그레이션 기간)

### 🔄 Migration Status
완료:
- License 모듈 (6개 UseCase)
- Warehouse Location 모듈 (5개 UseCase)

진행중:
- Auth 모듈 (2/5 UseCase)
- Company 모듈 (1/6 UseCase)

대기:
- User 모듈 (7개 UseCase)
- Equipment 모듈 (4개 UseCase)

### 🎯 Controller 통합
- 중복 Controller 제거 (with_usecase 버전)
- 단일 Controller로 통합
- UseCase 패턴 직접 적용

### 🧹 코드 정리
- 임시 파일 제거 (test_*.md, task.md)
- Node.js 아티팩트 제거 (package.json)
- 불필요한 테스트 파일 정리

###  테스트 개선
- Real API 중심 테스트 구조
- Mock 제거, 실제 API 엔드포인트 사용
- 통합 테스트 프레임워크 강화

## 기술적 영향
- 의존성 역전 원칙 적용
- 레이어 간 결합도 감소
- 테스트 용이성 향상
- 확장성 및 유지보수성 개선

## 다음 단계
1. User/Equipment 모듈 Repository 마이그레이션
2. Service Layer 점진적 제거
3. 캐싱 전략 구현
4. 성능 최적화
This commit is contained in:
JiWoong Sul
2025-08-11 20:14:10 +09:00
parent d64aa26157
commit 731dcd816b
105 changed files with 5225 additions and 3941 deletions

View File

@@ -103,16 +103,14 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
);
}).toList();
// 임시로 메타데이터 생성 (추후 API에서 실제 메타데이터 반환 시 수정)
// API에서 반환한 실제 메타데이터 사용
final meta = PaginationMeta(
currentPage: params.page,
perPage: params.perPage,
total: items.length < params.perPage ?
(params.page - 1) * params.perPage + items.length :
(params.page * params.perPage) + 1,
totalPages: items.length < params.perPage ? params.page : params.page + 1,
hasNext: items.length >= params.perPage,
hasPrevious: params.page > 1,
currentPage: apiEquipmentDtos.page,
perPage: apiEquipmentDtos.size,
total: apiEquipmentDtos.totalElements,
totalPages: apiEquipmentDtos.totalPages,
hasNext: !apiEquipmentDtos.last,
hasPrevious: !apiEquipmentDtos.first,
);
return PagedResult(items: items, meta: meta);

View File

@@ -168,10 +168,11 @@ class _EquipmentListState extends State<EquipmentList> {
/// 필터링된 장비 목록 반환
List<UnifiedEquipment> _getFilteredEquipments() {
// 서버에서 이미 페이지네이션된 데이터를 사용
var equipments = _controller.equipments;
print('DEBUG: Total equipments from controller: ${equipments.length}'); // 디버그 정보
// 검색 키워드 적용 (확장된 검색 필드)
// 로컬 검색 키워드 적용 (서버 검색과 병행)
// 서버에서 검색된 결과에 추가 로컬 필터링
if (_appliedSearchKeyword.isNotEmpty) {
equipments = equipments.where((e) {
final keyword = _appliedSearchKeyword.toLowerCase();
@@ -190,8 +191,6 @@ class _EquipmentListState extends State<EquipmentList> {
}).toList();
}
print('DEBUG: Filtered equipments count: ${equipments.length}'); // 디버그 정보
print('DEBUG: Selected status filter: $_selectedStatus'); // 디버그 정보
return equipments;
}
@@ -392,7 +391,8 @@ class _EquipmentListState extends State<EquipmentList> {
final int selectedRentCount = controller.getSelectedEquipmentCountByStatus(EquipmentStatus.rent);
final filteredEquipments = _getFilteredEquipments();
final totalCount = filteredEquipments.length;
// 백엔드 API에서 제공하는 실제 전체 아이템 수 사용
final totalCount = controller.total;
return BaseListScreen(
isLoading: controller.isLoading && controller.equipments.isEmpty,
@@ -414,8 +414,8 @@ class _EquipmentListState extends State<EquipmentList> {
dataTable: _buildDataTable(filteredEquipments),
// 페이지네이션
pagination: totalCount > controller.pageSize ? Pagination(
totalCount: totalCount,
pagination: controller.totalPages > 1 ? Pagination(
totalCount: controller.total,
currentPage: controller.currentPage,
pageSize: controller.pageSize,
onPageChanged: (page) {
@@ -944,17 +944,12 @@ class _EquipmentListState extends State<EquipmentList> {
/// 데이터 테이블
Widget _buildDataTable(List<UnifiedEquipment> filteredEquipments) {
final int startIndex = (_controller.currentPage - 1) * _controller.pageSize;
final int endIndex =
(startIndex + _controller.pageSize) > filteredEquipments.length
? filteredEquipments.length
: (startIndex + _controller.pageSize);
final List<UnifiedEquipment> pagedEquipments = filteredEquipments.sublist(
startIndex,
endIndex,
);
// 백엔드에서 이미 페이지네이션된 데이터를 받으므로
// 프론트엔드에서 추가 페이징 불필요
final List<UnifiedEquipment> pagedEquipments = filteredEquipments;
if (pagedEquipments.isEmpty) {
// 전체 데이터가 없는지 확인 (API의 total 사용)
if (_controller.total == 0 && pagedEquipments.isEmpty) {
return StandardEmptyState(
title:
_appliedSearchKeyword.isNotEmpty
@@ -1173,19 +1168,9 @@ class _EquipmentListState extends State<EquipmentList> {
/// 페이지 데이터 가져오기
List<UnifiedEquipment> _getPagedEquipments() {
final filteredEquipments = _getFilteredEquipments();
final int startIndex = (_controller.currentPage - 1) * _controller.pageSize;
final int endIndex = startIndex + _controller.pageSize;
if (startIndex >= filteredEquipments.length) {
return [];
}
final actualEndIndex = endIndex > filteredEquipments.length
? filteredEquipments.length
: endIndex;
return filteredEquipments.sublist(startIndex, actualEndIndex);
// 서버 페이지네이션 사용: 컨트롤러의 items가 이미 페이지네이션된 데이터
// 로컬 필터링만 적용
return _getFilteredEquipments();
}
/// 카테고리 축약 표기 함수