补充generatePath的cubit层
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
import '../../../../core/error/failure.dart';
|
||||
import '../../../auth/domain/errors/auth_failure.dart';
|
||||
import '../../data/models/device_add_path_point_model.dart';
|
||||
import '../../data/models/device_work_area_param_model.dart';
|
||||
import '../repositories/path_repository.dart';
|
||||
|
||||
abstract class GeneratePathUseCase {
|
||||
Future<List<DeviceAddPathPointModel>> execute({
|
||||
Future<Either<Failure, List<DeviceAddPathPointModel>>> execute({
|
||||
required ReferencePoint reference,
|
||||
required int heading,
|
||||
required OuterBoundary outer,
|
||||
@@ -11,27 +15,32 @@ abstract class GeneratePathUseCase {
|
||||
required int workType,
|
||||
});
|
||||
}
|
||||
|
||||
class GeneratePathUseCaseImpl implements GeneratePathUseCase {
|
||||
final PathRepository _repository;
|
||||
|
||||
GeneratePathUseCaseImpl(this._repository);
|
||||
//完成路径的生成
|
||||
|
||||
@override
|
||||
Future<List<DeviceAddPathPointModel>> execute({
|
||||
Future<Either<Failure, List<DeviceAddPathPointModel>>> execute({
|
||||
required ReferencePoint reference,
|
||||
required int heading,
|
||||
required OuterBoundary outer,
|
||||
required List<HoleBoundary> holes,
|
||||
required int workType,
|
||||
}) async {
|
||||
return await _repository.generatePath(
|
||||
reference: reference,
|
||||
heading: heading,
|
||||
outer: outer,
|
||||
holes: holes,
|
||||
workType: workType,
|
||||
);
|
||||
try {
|
||||
final result = await _repository.generatePath(
|
||||
reference: reference,
|
||||
heading: heading,
|
||||
outer: outer,
|
||||
holes: holes,
|
||||
workType: workType,
|
||||
);
|
||||
return Right(result); // 成功时返回 Right
|
||||
} catch (e) {
|
||||
return Left(ServerFailure(e.toString(),1)); // 失败时返回 Left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user