2026-02-28 12:46:29 +08:00
|
|
|
import 'package:fpdart/fpdart.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../core/error/failure.dart';
|
|
|
|
|
import '../../../auth/domain/errors/auth_failure.dart';
|
2026-02-26 10:09:59 +08:00
|
|
|
import '../../data/models/device_add_path_point_model.dart';
|
2026-02-26 16:20:02 +08:00
|
|
|
import '../../data/models/device_work_area_param_model.dart';
|
2026-02-26 10:09:59 +08:00
|
|
|
import '../repositories/path_repository.dart';
|
|
|
|
|
|
|
|
|
|
abstract class GeneratePathUseCase {
|
2026-02-28 12:46:29 +08:00
|
|
|
Future<Either<Failure, List<DeviceAddPathPointModel>>> execute({
|
2026-02-26 16:20:02 +08:00
|
|
|
required ReferencePoint reference,
|
|
|
|
|
required int heading,
|
|
|
|
|
required OuterBoundary outer,
|
|
|
|
|
required List<HoleBoundary> holes,
|
|
|
|
|
required int workType,
|
|
|
|
|
});
|
2026-02-26 10:09:59 +08:00
|
|
|
}
|
|
|
|
|
class GeneratePathUseCaseImpl implements GeneratePathUseCase {
|
|
|
|
|
final PathRepository _repository;
|
|
|
|
|
|
|
|
|
|
GeneratePathUseCaseImpl(this._repository);
|
2026-02-28 12:46:29 +08:00
|
|
|
|
2026-02-26 10:09:59 +08:00
|
|
|
@override
|
2026-02-28 12:46:29 +08:00
|
|
|
Future<Either<Failure, List<DeviceAddPathPointModel>>> execute({
|
2026-02-26 16:20:02 +08:00
|
|
|
required ReferencePoint reference,
|
|
|
|
|
required int heading,
|
|
|
|
|
required OuterBoundary outer,
|
|
|
|
|
required List<HoleBoundary> holes,
|
|
|
|
|
required int workType,
|
|
|
|
|
}) async {
|
2026-02-28 12:46:29 +08:00
|
|
|
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
|
|
|
|
|
}
|
2026-02-26 10:09:59 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-28 12:46:29 +08:00
|
|
|
|