61 lines
1.2 KiB
Dart
61 lines
1.2 KiB
Dart
class ExerciseTree {
|
|
/// treeId
|
|
int treeId;
|
|
|
|
/// parentId
|
|
int parentId;
|
|
|
|
/// name
|
|
String name;
|
|
|
|
/// imageUrl
|
|
String imageUrl;
|
|
|
|
/// active
|
|
bool active;
|
|
|
|
/// nameTranslation
|
|
String nameTranslation;
|
|
|
|
/// sort
|
|
int sort;
|
|
|
|
ExerciseTree();
|
|
|
|
ExerciseTree.fromJson(Map json) {
|
|
this.treeId = json['treeId'];
|
|
this.name = json['name'];
|
|
this.parentId = 0;
|
|
this.imageUrl = json['imageUrl'];
|
|
this.active = json['active'];
|
|
this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name;
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"treeId": treeId,
|
|
"parentId": parentId,
|
|
"name": name,
|
|
"imageUrl": imageUrl,
|
|
"active": active.toString(),
|
|
"nameTranslation": nameTranslation,
|
|
"sort": sort,
|
|
};
|
|
}
|
|
|
|
ExerciseTree copy(int parentId) {
|
|
ExerciseTree newTree = ExerciseTree();
|
|
newTree.treeId = this.treeId;
|
|
newTree.name = this.name;
|
|
newTree.imageUrl = this.imageUrl;
|
|
newTree.nameTranslation = this.nameTranslation;
|
|
if (parentId != -1) {
|
|
newTree.parentId = parentId;
|
|
}
|
|
newTree.active = this.active;
|
|
newTree.sort = this.sort;
|
|
|
|
return newTree;
|
|
}
|
|
}
|