Edit alert configuration

This commit is contained in:
2024-08-15 11:53:01 +08:00
parent 07f8112c7a
commit 22f3027d6f
9 changed files with 298 additions and 116 deletions

View File

@@ -0,0 +1,24 @@
class AlertConfiguration {
int nutrientId;
double maxValue;
double minValue;
AlertConfiguration({
required this.nutrientId,
required this.maxValue,
required this.minValue,
});
Map<String, dynamic> toJson() => {
'nutrient_id': nutrientId,
'min_value': minValue,
'max_value': maxValue,
};
factory AlertConfiguration.fromJson(Map<String, dynamic> json) =>
AlertConfiguration(
nutrientId: json['nutrient_id'],
minValue: json['min_value'],
maxValue: json['max_value'],
);
}

View File

@@ -98,7 +98,7 @@ class Nutrients {
}
class FoodSearchCriteria {
List<Type> dataType;
List<Type?> dataType;
String query;
String generalSearchInput;
int pageNumber;
@@ -107,7 +107,7 @@ class FoodSearchCriteria {
int numberOfResultsPerPage;
int pageSize;
bool requireAllWords;
List<Type> foodTypes;
List<Type?> foodTypes;
FoodSearchCriteria({
required this.dataType,
@@ -124,8 +124,8 @@ class FoodSearchCriteria {
factory FoodSearchCriteria.fromJson(Map<String, dynamic> json) =>
FoodSearchCriteria(
dataType:
List<Type>.from(json["dataType"].map((x) => typeValues.map[x]!)),
dataType: List<Type>.from(
json["dataType"]?.map((x) => typeValues.map[x]) ?? List.empty()),
query: json["query"],
generalSearchInput: json["generalSearchInput"],
pageNumber: json["pageNumber"],
@@ -134,8 +134,8 @@ class FoodSearchCriteria {
numberOfResultsPerPage: json["numberOfResultsPerPage"],
pageSize: json["pageSize"],
requireAllWords: json["requireAllWords"],
foodTypes:
List<Type>.from(json["foodTypes"].map((x) => typeValues.map[x]!)),
foodTypes: List<Type>.from(
json["foodTypes"]?.map((x) => typeValues.map[x]) ?? List.empty()),
);
Map<String, dynamic> toJson() => {
@@ -162,10 +162,10 @@ final typeValues =
class FoodData {
int fdcId;
String description;
String commonNames;
String additionalDescriptions;
Type dataType;
int ndbNumber;
String? commonNames;
String? additionalDescriptions;
Type? dataType;
int? ndbNumber;
DateTime publishedDate;
FoodCategory? foodCategory;
DateTime? mostRecentAcquisitionDate;
@@ -205,7 +205,7 @@ class FoodData {
description: json["description"],
commonNames: json["commonNames"],
additionalDescriptions: json["additionalDescriptions"],
dataType: typeValues.map[json["dataType"]]!,
dataType: typeValues.map[json["dataType"]],
ndbNumber: json["ndbNumber"],
publishedDate: DateTime.parse(json["publishedDate"]),
foodCategory: foodCategoryValues.map[json["foodCategory"]],
@@ -264,7 +264,7 @@ class FoodNutrient {
int nutrientId;
String nutrientName;
String nutrientNumber;
UnitName unitName;
UnitName? unitName;
DerivationCode? derivationCode;
String? derivationDescription;
int? derivationId;
@@ -305,15 +305,15 @@ class FoodNutrient {
nutrientId: json["nutrientId"],
nutrientName: json["nutrientName"],
nutrientNumber: json["nutrientNumber"],
unitName: unitNameValues.map[json["unitName"]]!,
derivationCode: derivationCodeValues.map[json["derivationCode"]]!,
unitName: unitNameValues.map[json["unitName"]],
derivationCode: derivationCodeValues.map[json["derivationCode"]],
derivationDescription: json["derivationDescription"],
derivationId: json["derivationId"],
value: json["value"]?.toDouble(),
foodNutrientSourceId: json["foodNutrientSourceId"],
foodNutrientSourceCode: json["foodNutrientSourceCode"],
foodNutrientSourceDescription: foodNutrientSourceDescriptionValues
.map[json["foodNutrientSourceDescription"]]!,
.map[json["foodNutrientSourceDescription"]],
rank: json["rank"],
indentLevel: json["indentLevel"],
foodNutrientId: json["foodNutrientId"],