refactor: 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

## 주요 변경사항

### 아키텍처 개선
- Clean Architecture 패턴 적용 (Domain, Data, Presentation 레이어 분리)
- Use Case 패턴 도입으로 비즈니스 로직 캡슐화
- Repository 패턴으로 데이터 접근 추상화
- 의존성 주입 구조 개선

### 상태 관리 최적화
- 모든 Controller에서 불필요한 상태 관리 로직 제거
- 페이지네이션 로직 통일 및 간소화
- 에러 처리 로직 개선 (에러 메시지 한글화)
- 로딩 상태 관리 최적화

### Mock 서비스 제거
- MockDataService 완전 제거
- 모든 화면을 실제 API 전용으로 전환
- 불필요한 Mock 관련 코드 정리

### UI/UX 개선
- Overview 화면 대시보드 기능 강화
- 라이선스 만료 알림 위젯 추가
- 사이드바 네비게이션 개선
- 일관된 UI 컴포넌트 사용

### 코드 품질
- 중복 코드 제거 및 함수 추출
- 파일별 책임 분리 명확화
- 테스트 코드 업데이트

## 영향 범위
- 모든 화면의 Controller 리팩토링
- API 통신 레이어 구조 개선
- 에러 처리 및 로깅 시스템 개선

## 향후 계획
- 단위 테스트 커버리지 확대
- 통합 테스트 시나리오 추가
- 성능 모니터링 도구 통합
This commit is contained in:
JiWoong Sul
2025-08-11 00:04:28 +09:00
parent 6b5d126990
commit 162fe08618
113 changed files with 11072 additions and 3319 deletions

View File

@@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:superport/models/address_model.dart';
import 'package:superport/models/company_model.dart';
import 'package:superport/services/mock_data_service.dart';
// import 'package:superport/services/mock_data_service.dart'; // Mock 서비스 제거
import 'package:superport/services/company_service.dart';
import 'package:superport/core/errors/failures.dart';
import 'package:superport/utils/phone_utils.dart';
@@ -21,7 +21,7 @@ import 'branch_form_controller.dart'; // 분리된 지점 컨트롤러 import
/// 회사 폼 컨트롤러 - 비즈니스 로직 처리
class CompanyFormController {
final MockDataService? dataService;
// final MockDataService? dataService; // Mock 서비스 제거
final CompanyService _companyService = GetIt.instance<CompanyService>();
final int? companyId;
@@ -77,7 +77,7 @@ class CompanyFormController {
bool preventAutoFocus = false;
final Map<int, bool> isNewlyAddedBranch = {};
CompanyFormController({this.dataService, this.companyId, bool useApi = false})
CompanyFormController({this.companyId, bool useApi = true})
: _useApi = useApi {
_setupFocusNodes();
_setupControllerListeners();
@@ -96,13 +96,8 @@ class CompanyFormController {
try {
List<Company> companies;
if (_useApi) {
companies = await _companyService.getCompanies();
} else if (dataService != null) {
companies = dataService!.getAllCompanies();
} else {
companies = [];
}
// API만 사용
companies = await _companyService.getCompanies();
companyNames = companies.map((c) => c.name).toList();
filteredCompanyNames = companyNames;
@@ -125,9 +120,9 @@ class CompanyFormController {
if (_useApi) {
debugPrint('📝 API에서 회사 정보 로드 중...');
company = await _companyService.getCompanyDetail(companyId!);
} else if (dataService != null) {
debugPrint('📝 Mock에서 회사 정보 로드 중...');
company = dataService!.getCompanyById(companyId!);
} else {
debugPrint('📝 API만 사용 가능');
throw Exception('API를 통해만 데이터를 로드할 수 있습니다');
}
debugPrint('📝 로드된 회사: $company');
@@ -234,8 +229,9 @@ class CompanyFormController {
debugPrint('Failed to load company data: ${e.message}');
return;
}
} else if (dataService != null) {
company = dataService!.getCompanyById(companyId!);
} else {
// API만 사용
debugPrint('API를 통해만 데이터를 로드할 수 있습니다');
}
if (company != null) {
@@ -364,8 +360,9 @@ class CompanyFormController {
// 오류 발생 시 중복 없음으로 처리
return null;
}
} else if (dataService != null) {
return dataService!.findCompanyByName(name);
} else {
// API만 사용
return null;
}
return null;
}
@@ -440,12 +437,9 @@ class CompanyFormController {
debugPrint('Unexpected error saving company: $e');
return false;
}
} else if (dataService != null) {
if (companyId == null) {
dataService!.addCompany(company);
} else {
dataService!.updateCompany(company);
}
} else {
// API만 사용
throw Exception('API를 통해만 데이터를 저장할 수 있습니다');
return true;
}
return false;
@@ -484,10 +478,9 @@ class CompanyFormController {
debugPrint('Failed to save branch: ${e.message}');
return false;
}
} else if (dataService != null) {
// Mock 데이터 서비스 사용
dataService!.updateBranch(companyId!, branch);
return true;
} else {
// API만 사용
return false;
}
return false;
}