41 lines
1.3 KiB
Dart
41 lines
1.3 KiB
Dart
import 'package:dio/dio.dart';
|
||
import 'package:get_it/get_it.dart';
|
||
import '../data/datasources/report_remote_datasource.dart';
|
||
import '../data/datasources/report_remote_datasource_impl.dart';
|
||
import '../data/repositories/report_repository_impl.dart';
|
||
import '../domain/repositories/report_repository.dart';
|
||
import '../domain/usecases/submit_report_usecase.dart';
|
||
import '../presentation/cubit/report_cubit.dart';
|
||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||
|
||
/// 上报模块依赖注入
|
||
class ReportDependencyInjector {
|
||
/// 创建 ReportCubit 实例
|
||
static ReportCubit createReportCubit() {
|
||
final sl = GetIt.I;
|
||
|
||
// 创建数据源
|
||
final ReportRemoteDataSource remoteDataSource =
|
||
ReportRemoteDataSourceImpl();
|
||
|
||
// 创建仓储
|
||
final ReportRepository repository = ReportRepositoryImpl(
|
||
remoteDataSource: remoteDataSource,
|
||
);
|
||
|
||
// 创建用例
|
||
final SubmitReportUseCase submitReportUseCase = SubmitReportUseCase(
|
||
repository,
|
||
);
|
||
|
||
// 创建 Cubit(注入 Dio、AppUserCubit、UserStorage)
|
||
return ReportCubit(
|
||
submitReportUseCase: submitReportUseCase,
|
||
dio: sl<Dio>(),
|
||
appUserCubit: sl<AppUserCubit>(),
|
||
userStorage: sl<UserStorage>(),
|
||
);
|
||
}
|
||
}
|