所有一级页面和不分二级页面
This commit is contained in:
36
lib/features/v2/report/domain/entities/report_entity.dart
Normal file
36
lib/features/v2/report/domain/entities/report_entity.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
/// 上报内容实体类
|
||||
class ReportEntity {
|
||||
final String? location;
|
||||
final String? reportType;
|
||||
final String? deviceId;
|
||||
final String? description;
|
||||
final List<String>? mediaUrls;
|
||||
final String? problemLevel;
|
||||
|
||||
const ReportEntity({
|
||||
this.location,
|
||||
this.reportType,
|
||||
this.deviceId,
|
||||
this.description,
|
||||
this.mediaUrls,
|
||||
this.problemLevel,
|
||||
});
|
||||
|
||||
ReportEntity copyWith({
|
||||
String? location,
|
||||
String? reportType,
|
||||
String? deviceId,
|
||||
String? description,
|
||||
List<String>? mediaUrls,
|
||||
String? problemLevel,
|
||||
}) {
|
||||
return ReportEntity(
|
||||
location: location ?? this.location,
|
||||
reportType: reportType ?? this.reportType,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
description: description ?? this.description,
|
||||
mediaUrls: mediaUrls ?? this.mediaUrls,
|
||||
problemLevel: problemLevel ?? this.problemLevel,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../../../core/error/failure.dart';
|
||||
import '../entities/report_entity.dart';
|
||||
|
||||
/// 上报仓储接口
|
||||
abstract class ReportRepository {
|
||||
/// 提交上报数据
|
||||
Future<Either<Failure, bool>> submitReport(ReportEntity report);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../../../core/error/failure.dart';
|
||||
import '../entities/report_entity.dart';
|
||||
import '../repositories/report_repository.dart';
|
||||
|
||||
/// 提交上报用例
|
||||
class SubmitReportUseCase {
|
||||
final ReportRepository repository;
|
||||
|
||||
SubmitReportUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, bool>> execute(ReportEntity report) async {
|
||||
// 业务逻辑验证
|
||||
if (report.deviceId == null || report.deviceId!.isEmpty) {
|
||||
return left(Failure('请选择设备'));
|
||||
}
|
||||
if (report.description == null || report.description!.isEmpty) {
|
||||
return left(Failure('请填写问题描述'));
|
||||
}
|
||||
if (report.problemLevel == null || report.problemLevel!.isEmpty) {
|
||||
return left(Failure('请选择问题等级'));
|
||||
}
|
||||
|
||||
return await repository.submitReport(report);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user