This commit is contained in:
wyf
2025-05-15 13:57:42 +08:00
parent fb5c3864a3
commit 75ddfca402
51 changed files with 2451 additions and 1233 deletions

View File

@@ -0,0 +1,33 @@
import 'package:ef/ef.dart';
import 'package:json_annotation/json_annotation.dart';
part 'sleep_report_controller.g.dart'; // 由json_serializable自动生成的部分
@JsonSerializable()
class SleepReportModel {
int? type = 1; //报告类型 1:日报 2.周报 3.月报
SleepReportModel();
// 从JSON反序列化时的异常处理
factory SleepReportModel.fromJson(Map<String, dynamic> json) {
try {
return _$SleepReportModelFromJson(json);
} catch (e) {
// 在实际应用中,应该有更细致的异常处理策略和错误日志
return SleepReportModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
}
}
// 序列化为JSON时的异常处理
Map<String, dynamic> toJson() => _$SleepReportModelToJson(this);
}
class SleepReportController extends GetControllerEx<SleepReportModel> {
Rx<DateTime?> selectedDate = Rx<DateTime?>(null);
SleepReportController() {
attr = GetModel(SleepReportModel()).obs;
}
}

View File

@@ -0,0 +1,15 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'sleep_report_controller.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SleepReportModel _$SleepReportModelFromJson(Map<String, dynamic> json) =>
SleepReportModel()..type = (json['type'] as num?)?.toInt();
Map<String, dynamic> _$SleepReportModelToJson(SleepReportModel instance) =>
<String, dynamic>{
'type': instance.type,
};