集成 获取用户设备的作业列表/删除作业列表/添加作业区域
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
import '../errors/device_failure.dart';
|
||||
import '../repositories/path_repository.dart';
|
||||
|
||||
class DeleteWorkRecordUseCase {
|
||||
final PathRepository repository;
|
||||
DeleteWorkRecordUseCase(this.repository);
|
||||
|
||||
Future<Either<DeviceFailure, Map<String, dynamic>>> call(String workName) async {
|
||||
try {
|
||||
final result = await repository.deleteWorkRecord(workName: workName);
|
||||
return Right(result);
|
||||
} catch (e) {
|
||||
return Left(DeviceFailure.networkError(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,37 @@
|
||||
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(List<DeviceAddPathPointModel> coordinates);
|
||||
Future<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<List<DeviceAddPathPointModel>> execute(List<DeviceAddPathPointModel> coordinates) async {
|
||||
return await _repository.generatePath(coordinates);
|
||||
Future<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,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../domain/errors/device_failure.dart';
|
||||
import '../../domain/repositories/path_repository.dart';
|
||||
|
||||
class GetWorkRecordUseCase {
|
||||
final PathRepository repository;
|
||||
|
||||
GetWorkRecordUseCase(this.repository);
|
||||
|
||||
Future<Either<DeviceFailure, List<Map<String, dynamic>>>> call(String userId) async {
|
||||
try {
|
||||
final result = await repository.getWorkRecord(userId: userId);
|
||||
return Right(result);
|
||||
} catch (e) {
|
||||
return Left(DeviceFailure.networkError(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user