refactor: Repository 패턴 적용 및 Clean Architecture 완성
## 주요 변경사항 ### 🏗️ 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:
@@ -60,7 +60,7 @@ Future<TestResult> runUserTests({
|
||||
if (response.statusCode == 200) {
|
||||
final users = response.data['data'] ?? [];
|
||||
if (verbose) {
|
||||
debugPrint('✅ 사용자 ${users.items.length}개 조회 성공');
|
||||
debugPrint('✅ 사용자 ${users.length}개 조회 성공');
|
||||
}
|
||||
passedTests++;
|
||||
} else {
|
||||
@@ -78,8 +78,8 @@ Future<TestResult> runUserTests({
|
||||
if (verbose) debugPrint('\n➕ 일반 사용자 생성 테스트...');
|
||||
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final nameIndex = random.nextInt(testUserData['names']!.items.length);
|
||||
final deptIndex = random.nextInt(testUserData['departments']!.items.length);
|
||||
final nameIndex = random.nextInt(testUserData['names']!.length);
|
||||
final deptIndex = random.nextInt(testUserData['departments']!.length);
|
||||
|
||||
try {
|
||||
final newUser = {
|
||||
@@ -88,7 +88,7 @@ Future<TestResult> runUserTests({
|
||||
'password': 'Password123!',
|
||||
'name': testUserData['names']![nameIndex],
|
||||
'department': testUserData['departments']![deptIndex],
|
||||
'position': testUserData['positions']![random.nextInt(testUserData['positions']!.items.length)],
|
||||
'position': testUserData['positions']![random.nextInt(testUserData['positions']!.length)],
|
||||
'phone': '010-${1000 + random.nextInt(9000)}-${1000 + random.nextInt(9000)}',
|
||||
'role': 'user', // 일반 사용자
|
||||
};
|
||||
@@ -169,14 +169,14 @@ Future<TestResult> runUserTests({
|
||||
totalTests++;
|
||||
if (verbose) debugPrint('\n🔍 사용자 상세 조회 테스트...');
|
||||
|
||||
if (createdUserIds.items.isEmpty) {
|
||||
if (createdUserIds.isEmpty) {
|
||||
failedTestNames.add('사용자 상세 조회');
|
||||
if (verbose) debugPrint('⚠️ 조회할 사용자가 없음');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final userId = createdUserIds.items.first;
|
||||
final userId = createdUserIds.first;
|
||||
final response = await dio.get('$baseUrl/users/$userId');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -204,14 +204,14 @@ Future<TestResult> runUserTests({
|
||||
totalTests++;
|
||||
if (verbose) debugPrint('\n✏️ 사용자 정보 수정 테스트...');
|
||||
|
||||
if (createdUserIds.items.isEmpty) {
|
||||
if (createdUserIds.isEmpty) {
|
||||
failedTestNames.add('사용자 정보 수정');
|
||||
if (verbose) debugPrint('⚠️ 수정할 사용자가 없음');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final userId = createdUserIds.items.first;
|
||||
final userId = createdUserIds.first;
|
||||
final updatedData = {
|
||||
'name': '수정된이름_${random.nextInt(1000)}',
|
||||
'department': '수정된부서',
|
||||
@@ -243,14 +243,14 @@ Future<TestResult> runUserTests({
|
||||
totalTests++;
|
||||
if (verbose) debugPrint('\n🔐 비밀번호 변경 테스트...');
|
||||
|
||||
if (createdUserIds.items.isEmpty) {
|
||||
if (createdUserIds.isEmpty) {
|
||||
failedTestNames.add('비밀번호 변경');
|
||||
if (verbose) debugPrint('⚠️ 대상 사용자가 없음');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final userId = createdUserIds.items.first;
|
||||
final userId = createdUserIds.first;
|
||||
final passwordData = {
|
||||
'current_password': 'Password123!',
|
||||
'new_password': 'NewPassword456!',
|
||||
@@ -281,7 +281,7 @@ Future<TestResult> runUserTests({
|
||||
totalTests++;
|
||||
if (verbose) debugPrint('\n👤 사용자 권한 변경 테스트...');
|
||||
|
||||
if (createdUserIds.items.length < 2) {
|
||||
if (createdUserIds.length < 2) {
|
||||
failedTestNames.add('사용자 권한 변경');
|
||||
if (verbose) debugPrint('⚠️ 권한 변경할 사용자가 부족');
|
||||
return;
|
||||
@@ -317,14 +317,14 @@ Future<TestResult> runUserTests({
|
||||
totalTests++;
|
||||
if (verbose) debugPrint('\n🔄 사용자 비활성화/활성화 테스트...');
|
||||
|
||||
if (createdUserIds.items.isEmpty) {
|
||||
if (createdUserIds.isEmpty) {
|
||||
failedTestNames.add('사용자 비활성화/활성화');
|
||||
if (verbose) debugPrint('⚠️ 대상 사용자가 없음');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final userId = createdUserIds.items.first;
|
||||
final userId = createdUserIds.first;
|
||||
|
||||
// 비활성화
|
||||
var response = await dio.patch(
|
||||
@@ -375,7 +375,7 @@ Future<TestResult> runUserTests({
|
||||
if (response.statusCode == 200) {
|
||||
final results = response.data['data'] ?? [];
|
||||
if (verbose) {
|
||||
debugPrint('✅ 사용자 검색 성공: ${results.items.length}개 결과');
|
||||
debugPrint('✅ 사용자 검색 성공: ${results.length}개 결과');
|
||||
}
|
||||
passedTests++;
|
||||
} else {
|
||||
@@ -392,7 +392,7 @@ Future<TestResult> runUserTests({
|
||||
totalTests++;
|
||||
if (verbose) debugPrint('\n🗑️ 사용자 삭제 테스트...');
|
||||
|
||||
if (createdUserIds.items.isEmpty) {
|
||||
if (createdUserIds.isEmpty) {
|
||||
failedTestNames.add('사용자 삭제');
|
||||
if (verbose) debugPrint('⚠️ 삭제할 사용자가 없음');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user