47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
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<Either<Failure, List<DeviceAddPathPointModel>>> execute({
|
|
required ReferencePoint reference,
|
|
required int heading,
|
|
required OuterBoundary outer,
|
|
required List<HoleBoundary> holes,
|
|
required int workType,
|
|
});
|
|
}
|
|
class GeneratePathUseCaseImpl implements GeneratePathUseCase {
|
|
final PathRepository _repository;
|
|
|
|
GeneratePathUseCaseImpl(this._repository);
|
|
|
|
@override
|
|
Future<Either<Failure, List<DeviceAddPathPointModel>>> execute({
|
|
required ReferencePoint reference,
|
|
required int heading,
|
|
required OuterBoundary outer,
|
|
required List<HoleBoundary> holes,
|
|
required int workType,
|
|
}) async {
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|
|
|