Merge branch 'feature/my' of http://1.95.137.212:57001/APP/FlutterApp into feature/my
This commit is contained in:
@@ -34,6 +34,8 @@ import '../../features/devices/domain/usecases/device_work_hostrirty_usecase.dar
|
|||||||
import '../../features/devices/domain/usecases/generate_path_usecase.dart';
|
import '../../features/devices/domain/usecases/generate_path_usecase.dart';
|
||||||
import '../../features/devices/domain/usecases/get_device_location_usecase.dart';
|
import '../../features/devices/domain/usecases/get_device_location_usecase.dart';
|
||||||
import '../../features/devices/domain/usecases/get_work_record_usecase.dart';
|
import '../../features/devices/domain/usecases/get_work_record_usecase.dart';
|
||||||
|
import '../../features/devices/domain/usecases/save_work_record_usecase.dart';
|
||||||
|
import '../../features/devices/domain/usecases/select_work_record_usecase.dart';
|
||||||
import '../../features/remote_control/presentation/bloc/remote_control_cubit.dart';
|
import '../../features/remote_control/presentation/bloc/remote_control_cubit.dart';
|
||||||
import '../app/app_user_cubit.dart';
|
import '../app/app_user_cubit.dart';
|
||||||
import '../network/dio_client.dart';
|
import '../network/dio_client.dart';
|
||||||
@@ -104,8 +106,10 @@ Future<void> init() async {
|
|||||||
sl.registerLazySingleton(() => GetUserDeviceUseCase(sl()));
|
sl.registerLazySingleton(() => GetUserDeviceUseCase(sl()));
|
||||||
sl.registerLazySingleton(() => DiffSteerUseCase());
|
sl.registerLazySingleton(() => DiffSteerUseCase());
|
||||||
sl.registerLazySingleton(() => DeviceWorkHostrirty(sl()));
|
sl.registerLazySingleton(() => DeviceWorkHostrirty(sl()));
|
||||||
|
sl.registerLazySingleton<SelectWorkRecordUseCase>(() => SelectWorkRecordUseCase(sl<PathRepository>()));
|
||||||
sl.registerLazySingleton(() => UnbindDeviceUseCase(sl()));
|
sl.registerLazySingleton(() => UnbindDeviceUseCase(sl()));
|
||||||
sl.registerLazySingleton(() => UpdateDevicenameUsecase(sl()));
|
sl.registerLazySingleton(() => UpdateDevicenameUsecase(sl()));
|
||||||
|
sl.registerLazySingleton<SaveWorkRecordUseCase>(() => SaveWorkRecordUseCase(sl<PathRepository>()));
|
||||||
|
|
||||||
sl.registerLazySingleton(() => SelectWorkRecordUseCase(sl()));
|
sl.registerLazySingleton(() => SelectWorkRecordUseCase(sl()));
|
||||||
|
|
||||||
@@ -113,7 +117,7 @@ Future<void> init() async {
|
|||||||
sl.registerLazySingleton(() => AppUserCubit()); // AuthCubit 依赖它,必须先注册
|
sl.registerLazySingleton(() => AppUserCubit()); // AuthCubit 依赖它,必须先注册
|
||||||
sl.registerLazySingleton(() => GetDeviceLocationUseCase(sl()));
|
sl.registerLazySingleton(() => GetDeviceLocationUseCase(sl()));
|
||||||
sl.registerLazySingleton(
|
sl.registerLazySingleton(
|
||||||
() => DevicesCubit(sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl()),
|
() => DevicesCubit(sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl()),
|
||||||
);
|
);
|
||||||
sl.registerFactory(() => RemoteControlCubit(sl()));
|
sl.registerFactory(() => RemoteControlCubit(sl()));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// lib/features/devices/domain/usecases/save_work_record_usecase.dart
|
||||||
|
import 'package:fpdart/fpdart.dart';
|
||||||
|
import '../../domain/errors/device_failure.dart';
|
||||||
|
import '../../domain/repositories/path_repository.dart';
|
||||||
|
|
||||||
|
class SaveWorkRecordUseCase {
|
||||||
|
final PathRepository repository;
|
||||||
|
|
||||||
|
SaveWorkRecordUseCase(this.repository);
|
||||||
|
|
||||||
|
Future<Either<DeviceFailure, Map<String, dynamic>>> call({
|
||||||
|
required String workName,
|
||||||
|
required String userId,
|
||||||
|
required String jsonData,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final result = await repository.saveWorkRecord(
|
||||||
|
workName: workName,
|
||||||
|
userId: userId,
|
||||||
|
jsonData: jsonData,
|
||||||
|
);
|
||||||
|
return Right(result);
|
||||||
|
} catch (e) {
|
||||||
|
return Left(DeviceFailure.networkError(message: e.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||||
import 'package:maibu_satabot_v2/features/devices/domain/repositories/device_repository.dart';
|
import 'package:maibu_satabot_v2/features/devices/domain/repositories/device_repository.dart';
|
||||||
import 'package:maibu_satabot_v2/features/devices/domain/usecases/get_user_device_usecase.dart';
|
import 'package:maibu_satabot_v2/features/devices/domain/usecases/get_user_device_usecase.dart';
|
||||||
|
import 'package:maibu_satabot_v2/features/devices/domain/usecases/save_work_record_usecase.dart';
|
||||||
import 'package:maibu_satabot_v2/features/devices/domain/usecases/select_work_record_usecase.dart';
|
import 'package:maibu_satabot_v2/features/devices/domain/usecases/select_work_record_usecase.dart';
|
||||||
import 'package:maibu_satabot_v2/features/devices/domain/usecases/unbind_device_usecase.dart';
|
import 'package:maibu_satabot_v2/features/devices/domain/usecases/unbind_device_usecase.dart';
|
||||||
import 'package:maibu_satabot_v2/features/devices/domain/usecases/update_devicename_usecase.dart';
|
import 'package:maibu_satabot_v2/features/devices/domain/usecases/update_devicename_usecase.dart';
|
||||||
@@ -21,6 +22,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
final UnbindDeviceUseCase _unbindDeviceUseCase;
|
final UnbindDeviceUseCase _unbindDeviceUseCase;
|
||||||
final UpdateDevicenameUsecase _updateDevicename;
|
final UpdateDevicenameUsecase _updateDevicename;
|
||||||
final SelectWorkRecordUseCase _selectWorkRecordUseCase;
|
final SelectWorkRecordUseCase _selectWorkRecordUseCase;
|
||||||
|
final SaveWorkRecordUseCase _saveWorkRecordUseCase;
|
||||||
|
|
||||||
DevicesCubit(
|
DevicesCubit(
|
||||||
this.repository,
|
this.repository,
|
||||||
@@ -31,6 +33,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
this._unbindDeviceUseCase,
|
this._unbindDeviceUseCase,
|
||||||
this._updateDevicename,
|
this._updateDevicename,
|
||||||
this._selectWorkRecordUseCase,
|
this._selectWorkRecordUseCase,
|
||||||
|
this._saveWorkRecordUseCase,
|
||||||
) : super(const DevicesState());
|
) : super(const DevicesState());
|
||||||
|
|
||||||
Future<void> unbindDevice(String deviceId, String deviceName) async {
|
Future<void> unbindDevice(String deviceId, String deviceName) async {
|
||||||
@@ -282,4 +285,19 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
emit(state.copyWith(isLoading: false, errorMessage: e.toString()));
|
emit(state.copyWith(isLoading: false, errorMessage: e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// 保存路径数据
|
||||||
|
Future<void> saveWorkRecord(String workName, String userId, String jsonData) async {
|
||||||
|
emit(state.copyWith(isLoading: true));
|
||||||
|
final result = await _saveWorkRecordUseCase.call(
|
||||||
|
workName: workName,
|
||||||
|
userId: userId,
|
||||||
|
jsonData: jsonData,
|
||||||
|
);
|
||||||
|
result.fold(
|
||||||
|
(failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message)),
|
||||||
|
(data) => emit(state.copyWith(isLoading: false)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user