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:
@@ -5,9 +5,14 @@
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i4;
|
||||
|
||||
import 'package:dartz/dartz.dart' as _i2;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:superport/data/models/license/license_dto.dart' as _i2;
|
||||
import 'package:superport/data/repositories/license_repository.dart' as _i3;
|
||||
import 'package:superport/core/errors/failures.dart' as _i5;
|
||||
import 'package:superport/data/models/common/paginated_response.dart' as _i6;
|
||||
import 'package:superport/data/models/dashboard/license_expiry_summary.dart'
|
||||
as _i8;
|
||||
import 'package:superport/domain/repositories/license_repository.dart' as _i3;
|
||||
import 'package:superport/models/license_model.dart' as _i7;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -23,19 +28,8 @@ import 'package:superport/data/repositories/license_repository.dart' as _i3;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeLicenseListResponseDto_0 extends _i1.SmartFake
|
||||
implements _i2.LicenseListResponseDto {
|
||||
_FakeLicenseListResponseDto_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
parent,
|
||||
parentInvocation,
|
||||
);
|
||||
}
|
||||
|
||||
class _FakeLicenseDto_1 extends _i1.SmartFake implements _i2.LicenseDto {
|
||||
_FakeLicenseDto_1(
|
||||
class _FakeEither_0<L, R> extends _i1.SmartFake implements _i2.Either<L, R> {
|
||||
_FakeEither_0(
|
||||
Object parent,
|
||||
Invocation parentInvocation,
|
||||
) : super(
|
||||
@@ -53,11 +47,16 @@ class MockLicenseRepository extends _i1.Mock implements _i3.LicenseRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.LicenseListResponseDto> getLicenses({
|
||||
int? page = 1,
|
||||
int? perPage = 20,
|
||||
_i4.Future<
|
||||
_i2.Either<_i5.Failure, _i6.PaginatedResponse<_i7.License>>> getLicenses({
|
||||
int? page,
|
||||
int? limit,
|
||||
String? search,
|
||||
Map<String, dynamic>? filters,
|
||||
int? companyId,
|
||||
String? equipmentType,
|
||||
String? expiryStatus,
|
||||
String? sortBy,
|
||||
String? sortOrder,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -65,90 +64,305 @@ class MockLicenseRepository extends _i1.Mock implements _i3.LicenseRepository {
|
||||
[],
|
||||
{
|
||||
#page: page,
|
||||
#perPage: perPage,
|
||||
#limit: limit,
|
||||
#search: search,
|
||||
#filters: filters,
|
||||
#companyId: companyId,
|
||||
#equipmentType: equipmentType,
|
||||
#expiryStatus: expiryStatus,
|
||||
#sortBy: sortBy,
|
||||
#sortOrder: sortOrder,
|
||||
},
|
||||
),
|
||||
returnValue: _i4.Future<_i2.LicenseListResponseDto>.value(
|
||||
_FakeLicenseListResponseDto_0(
|
||||
returnValue: _i4.Future<
|
||||
_i2
|
||||
.Either<_i5.Failure, _i6.PaginatedResponse<_i7.License>>>.value(
|
||||
_FakeEither_0<_i5.Failure, _i6.PaginatedResponse<_i7.License>>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getLicenses,
|
||||
[],
|
||||
{
|
||||
#page: page,
|
||||
#perPage: perPage,
|
||||
#limit: limit,
|
||||
#search: search,
|
||||
#filters: filters,
|
||||
#companyId: companyId,
|
||||
#equipmentType: equipmentType,
|
||||
#expiryStatus: expiryStatus,
|
||||
#sortBy: sortBy,
|
||||
#sortOrder: sortOrder,
|
||||
},
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.LicenseListResponseDto>);
|
||||
) as _i4
|
||||
.Future<_i2.Either<_i5.Failure, _i6.PaginatedResponse<_i7.License>>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.LicenseDto> getLicenseDetail(int? id) => (super.noSuchMethod(
|
||||
_i4.Future<_i2.Either<_i5.Failure, _i7.License>> getLicenseById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getLicenseDetail,
|
||||
#getLicenseById,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i4.Future<_i2.LicenseDto>.value(_FakeLicenseDto_1(
|
||||
returnValue: _i4.Future<_i2.Either<_i5.Failure, _i7.License>>.value(
|
||||
_FakeEither_0<_i5.Failure, _i7.License>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getLicenseDetail,
|
||||
#getLicenseById,
|
||||
[id],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.LicenseDto>);
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, _i7.License>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.LicenseDto> createLicense(Map<String, dynamic>? data) =>
|
||||
_i4.Future<_i2.Either<_i5.Failure, _i7.License>> createLicense(
|
||||
_i7.License? license) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#createLicense,
|
||||
[data],
|
||||
[license],
|
||||
),
|
||||
returnValue: _i4.Future<_i2.LicenseDto>.value(_FakeLicenseDto_1(
|
||||
returnValue: _i4.Future<_i2.Either<_i5.Failure, _i7.License>>.value(
|
||||
_FakeEither_0<_i5.Failure, _i7.License>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#createLicense,
|
||||
[data],
|
||||
[license],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.LicenseDto>);
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, _i7.License>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.LicenseDto> updateLicense(
|
||||
_i4.Future<_i2.Either<_i5.Failure, _i7.License>> updateLicense(
|
||||
int? id,
|
||||
Map<String, dynamic>? data,
|
||||
_i7.License? license,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#updateLicense,
|
||||
[
|
||||
id,
|
||||
data,
|
||||
license,
|
||||
],
|
||||
),
|
||||
returnValue: _i4.Future<_i2.LicenseDto>.value(_FakeLicenseDto_1(
|
||||
returnValue: _i4.Future<_i2.Either<_i5.Failure, _i7.License>>.value(
|
||||
_FakeEither_0<_i5.Failure, _i7.License>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#updateLicense,
|
||||
[
|
||||
id,
|
||||
data,
|
||||
license,
|
||||
],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.LicenseDto>);
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, _i7.License>>);
|
||||
|
||||
@override
|
||||
_i4.Future<void> deleteLicense(int? id) => (super.noSuchMethod(
|
||||
_i4.Future<_i2.Either<_i5.Failure, void>> deleteLicense(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteLicense,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i4.Future<void>.value(),
|
||||
returnValueForMissingStub: _i4.Future<void>.value(),
|
||||
) as _i4.Future<void>);
|
||||
returnValue: _i4.Future<_i2.Either<_i5.Failure, void>>.value(
|
||||
_FakeEither_0<_i5.Failure, void>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#deleteLicense,
|
||||
[id],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, void>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>> getExpiringLicenses({
|
||||
int? days = 30,
|
||||
int? companyId,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getExpiringLicenses,
|
||||
[],
|
||||
{
|
||||
#days: days,
|
||||
#companyId: companyId,
|
||||
},
|
||||
),
|
||||
returnValue:
|
||||
_i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>>.value(
|
||||
_FakeEither_0<_i5.Failure, List<_i7.License>>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getExpiringLicenses,
|
||||
[],
|
||||
{
|
||||
#days: days,
|
||||
#companyId: companyId,
|
||||
},
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>> getExpiredLicenses(
|
||||
{int? companyId}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getExpiredLicenses,
|
||||
[],
|
||||
{#companyId: companyId},
|
||||
),
|
||||
returnValue:
|
||||
_i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>>.value(
|
||||
_FakeEither_0<_i5.Failure, List<_i7.License>>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getExpiredLicenses,
|
||||
[],
|
||||
{#companyId: companyId},
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, _i8.LicenseExpirySummary>>
|
||||
getLicenseExpirySummary() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getLicenseExpirySummary,
|
||||
[],
|
||||
),
|
||||
returnValue: _i4.Future<
|
||||
_i2.Either<_i5.Failure, _i8.LicenseExpirySummary>>.value(
|
||||
_FakeEither_0<_i5.Failure, _i8.LicenseExpirySummary>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getLicenseExpirySummary,
|
||||
[],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, _i8.LicenseExpirySummary>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, _i7.License>> renewLicense(
|
||||
int? id,
|
||||
DateTime? newExpiryDate, {
|
||||
double? renewalCost,
|
||||
String? renewalNote,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#renewLicense,
|
||||
[
|
||||
id,
|
||||
newExpiryDate,
|
||||
],
|
||||
{
|
||||
#renewalCost: renewalCost,
|
||||
#renewalNote: renewalNote,
|
||||
},
|
||||
),
|
||||
returnValue: _i4.Future<_i2.Either<_i5.Failure, _i7.License>>.value(
|
||||
_FakeEither_0<_i5.Failure, _i7.License>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#renewLicense,
|
||||
[
|
||||
id,
|
||||
newExpiryDate,
|
||||
],
|
||||
{
|
||||
#renewalCost: renewalCost,
|
||||
#renewalNote: renewalNote,
|
||||
},
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, _i7.License>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, Map<String, int>>>
|
||||
getLicenseStatsByCompany(int? companyId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getLicenseStatsByCompany,
|
||||
[companyId],
|
||||
),
|
||||
returnValue:
|
||||
_i4.Future<_i2.Either<_i5.Failure, Map<String, int>>>.value(
|
||||
_FakeEither_0<_i5.Failure, Map<String, int>>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getLicenseStatsByCompany,
|
||||
[companyId],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, Map<String, int>>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, Map<String, int>>>
|
||||
getLicenseCountByType() => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#getLicenseCountByType,
|
||||
[],
|
||||
),
|
||||
returnValue:
|
||||
_i4.Future<_i2.Either<_i5.Failure, Map<String, int>>>.value(
|
||||
_FakeEither_0<_i5.Failure, Map<String, int>>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#getLicenseCountByType,
|
||||
[],
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, Map<String, int>>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, void>> setExpiryNotification(
|
||||
int? licenseId, {
|
||||
int? notifyDays = 30,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#setExpiryNotification,
|
||||
[licenseId],
|
||||
{#notifyDays: notifyDays},
|
||||
),
|
||||
returnValue: _i4.Future<_i2.Either<_i5.Failure, void>>.value(
|
||||
_FakeEither_0<_i5.Failure, void>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#setExpiryNotification,
|
||||
[licenseId],
|
||||
{#notifyDays: notifyDays},
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, void>>);
|
||||
|
||||
@override
|
||||
_i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>> searchLicenses(
|
||||
String? query, {
|
||||
int? companyId,
|
||||
int? limit,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#searchLicenses,
|
||||
[query],
|
||||
{
|
||||
#companyId: companyId,
|
||||
#limit: limit,
|
||||
},
|
||||
),
|
||||
returnValue:
|
||||
_i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>>.value(
|
||||
_FakeEither_0<_i5.Failure, List<_i7.License>>(
|
||||
this,
|
||||
Invocation.method(
|
||||
#searchLicenses,
|
||||
[query],
|
||||
{
|
||||
#companyId: companyId,
|
||||
#limit: limit,
|
||||
},
|
||||
),
|
||||
)),
|
||||
) as _i4.Future<_i2.Either<_i5.Failure, List<_i7.License>>>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user