39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'package:ef/ef.dart';
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'common_message_setting_controller.g.dart'; // 由json_serializable自动生成的部分
|
|
|
|
@JsonSerializable()
|
|
class CommonMessageSettingModel {
|
|
int? setting = 0;//总设置 0 关闭 1 开启
|
|
int? appSetting = 0;//app消息设置
|
|
int? serviceSetting = 0;//服务号消息
|
|
int? tipSetting = 0;//设备放置说明
|
|
int? deviceUpgradeSetting = 0;//设备升级提示
|
|
int? deviceIssueSetting = 0;//设备故障提示
|
|
|
|
|
|
CommonMessageSettingModel();
|
|
|
|
// 从JSON反序列化时的异常处理
|
|
|
|
factory CommonMessageSettingModel.fromJson(Map<String, dynamic> json) {
|
|
try {
|
|
return _$CommonMessageSettingModelFromJson(json);
|
|
} catch (e) {
|
|
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
|
return CommonMessageSettingModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
|
}
|
|
}
|
|
|
|
// 序列化为JSON时的异常处理
|
|
Map<String, dynamic> toJson() => _$CommonMessageSettingModelToJson(this);
|
|
}
|
|
|
|
class CommonMessageSettingController extends GetControllerEx<CommonMessageSettingModel> {
|
|
CommonMessageSettingController() {
|
|
attr = GetModel(CommonMessageSettingModel()).obs;
|
|
}
|
|
|
|
}
|