基本完成
This commit is contained in:
15
lib/api/dto/base_dto.dart
Normal file
15
lib/api/dto/base_dto.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
class ApiDto<T> {
|
||||
final int code;
|
||||
final String message;
|
||||
final T data;
|
||||
|
||||
ApiDto({required this.code, required this.message, required this.data});
|
||||
|
||||
factory ApiDto.fromJson(Map<String, dynamic> json) {
|
||||
return ApiDto<T>(
|
||||
code: json['code'],
|
||||
message: json['message'],
|
||||
data: json['data'],
|
||||
);
|
||||
}
|
||||
}
|
||||
49
lib/api/dto/food_scan_dto.dart
Normal file
49
lib/api/dto/food_scan_dto.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
class FoodScanDto {
|
||||
int? id;
|
||||
String? foodName;
|
||||
String? foodDesc;
|
||||
List<String>? ingredientsList;
|
||||
String? explanation;
|
||||
String? suggestions;
|
||||
List<String>? healthConcernsList;
|
||||
int? foodType;
|
||||
String? imageUrl;
|
||||
|
||||
FoodScanDto({
|
||||
this.id,
|
||||
this.foodName,
|
||||
this.foodDesc,
|
||||
this.ingredientsList,
|
||||
this.explanation,
|
||||
this.suggestions,
|
||||
this.healthConcernsList,
|
||||
this.foodType,
|
||||
this.imageUrl,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map["id"] = id;
|
||||
map["food_name"] = foodName;
|
||||
map["food_desc"] = foodDesc;
|
||||
map["ingredients"] = ingredientsList;
|
||||
map["explanation"] = explanation;
|
||||
map["suggestions"] = suggestions;
|
||||
map["health_concerns"] = healthConcernsList;
|
||||
map["food_type"] = foodType;
|
||||
map["image_url"] = imageUrl;
|
||||
return map;
|
||||
}
|
||||
|
||||
FoodScanDto.fromJson(dynamic json) {
|
||||
id = json["id"] ?? 0;
|
||||
foodName = json["food_name"] ?? "";
|
||||
foodDesc = json["food_desc"] ?? "";
|
||||
ingredientsList = json["ingredients"] != null ? json["ingredients"].cast<String>() : [];
|
||||
explanation = json["explanation"] ?? "";
|
||||
suggestions = json["suggestions"] ?? "";
|
||||
healthConcernsList = json["health_concerns"] != null ? json["health_concerns"].cast<String>() : [];
|
||||
foodType = json["food_type"] ?? 0;
|
||||
imageUrl = json["image_url"] ?? "";
|
||||
}
|
||||
}
|
||||
86
lib/api/dto/login_dto.dart
Normal file
86
lib/api/dto/login_dto.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
class UserInfo {
|
||||
int? id;
|
||||
String? name;
|
||||
dynamic avatar;
|
||||
String? email;
|
||||
dynamic emailVerifiedAt;
|
||||
dynamic googleId;
|
||||
dynamic appleId;
|
||||
String? lastLoginIp;
|
||||
String? lastLoginTime;
|
||||
dynamic lastUsedTime;
|
||||
int? status;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
|
||||
UserInfo({
|
||||
this.id,
|
||||
this.name,
|
||||
this.avatar,
|
||||
this.email,
|
||||
this.emailVerifiedAt,
|
||||
this.googleId,
|
||||
this.appleId,
|
||||
this.lastLoginIp,
|
||||
this.lastLoginTime,
|
||||
this.lastUsedTime,
|
||||
this.status,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map["id"] = id;
|
||||
map["name"] = name;
|
||||
map["avatar"] = avatar;
|
||||
map["email"] = email;
|
||||
map["email_verified_at"] = emailVerifiedAt;
|
||||
map["google_id"] = googleId;
|
||||
map["apple_id"] = appleId;
|
||||
map["last_login_ip"] = lastLoginIp;
|
||||
map["last_login_time"] = lastLoginTime;
|
||||
map["last_used_time"] = lastUsedTime;
|
||||
map["status"] = status;
|
||||
map["created_at"] = createdAt;
|
||||
map["updated_at"] = updatedAt;
|
||||
return map;
|
||||
}
|
||||
|
||||
UserInfo.fromJson(dynamic json) {
|
||||
id = json["id"] ?? 0;
|
||||
name = json["name"] ?? "";
|
||||
avatar = json["avatar"];
|
||||
email = json["email"] ?? "";
|
||||
emailVerifiedAt = json["email_verified_at"];
|
||||
googleId = json["google_id"];
|
||||
appleId = json["apple_id"];
|
||||
lastLoginIp = json["last_login_ip"] ?? "";
|
||||
lastLoginTime = json["last_login_time"] ?? "";
|
||||
lastUsedTime = json["last_used_time"];
|
||||
status = json["status"] ?? 0;
|
||||
createdAt = json["created_at"] ?? "";
|
||||
updatedAt = json["updated_at"] ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
class LoginDto {
|
||||
String? accessToken;
|
||||
UserInfo? userInfo;
|
||||
|
||||
LoginDto({this.accessToken, this.userInfo});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map["accessToken"] = accessToken;
|
||||
if (userInfo != null) {
|
||||
map["userInfo"] = userInfo?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
LoginDto.fromJson(dynamic json) {
|
||||
accessToken = json["accessToken"] ?? "";
|
||||
userInfo = json["userInfo"] != null ? UserInfo.fromJson(json["userInfo"]) : null;
|
||||
}
|
||||
}
|
||||
18
lib/api/dto/profile_options_dto.dart
Normal file
18
lib/api/dto/profile_options_dto.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
class ProfileOptionDto {
|
||||
String? key;
|
||||
List<String>? valuesList;
|
||||
|
||||
ProfileOptionDto({this.key, this.valuesList});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map["key"] = key;
|
||||
map["values"] = valuesList;
|
||||
return map;
|
||||
}
|
||||
|
||||
ProfileOptionDto.fromJson(dynamic json) {
|
||||
key = json["key"] ?? "";
|
||||
valuesList = json["values"] != null ? json["values"].cast<String>() : [];
|
||||
}
|
||||
}
|
||||
58
lib/api/dto/user_profile_dto.dart
Normal file
58
lib/api/dto/user_profile_dto.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
class UserProfileDto {
|
||||
num id;
|
||||
String name;
|
||||
String email;
|
||||
String avatar;
|
||||
String ageRange;
|
||||
List<String> foodAllergiesList;
|
||||
List<String> dietaryPreferencesList;
|
||||
List<String> medicalInformationList;
|
||||
List<String> currentMedicationsList;
|
||||
String activityLevel;
|
||||
|
||||
UserProfileDto({
|
||||
this.id = 0,
|
||||
this.name = "",
|
||||
this.email = "",
|
||||
this.avatar = "",
|
||||
this.ageRange = "",
|
||||
List<String>? foodAllergiesList,
|
||||
List<String>? dietaryPreferencesList,
|
||||
List<String>? medicalInformationList,
|
||||
List<String>? currentMedicationsList,
|
||||
this.activityLevel = "",
|
||||
}) : foodAllergiesList = foodAllergiesList ?? [],
|
||||
dietaryPreferencesList = dietaryPreferencesList ?? [],
|
||||
medicalInformationList = medicalInformationList ?? [],
|
||||
currentMedicationsList = currentMedicationsList ?? [];
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"email": email,
|
||||
"avatar": avatar,
|
||||
"age_range": ageRange,
|
||||
"food_allergies": foodAllergiesList,
|
||||
"dietary_preferences": dietaryPreferencesList,
|
||||
"medical_information": medicalInformationList,
|
||||
"current_medications": currentMedicationsList,
|
||||
"activity_level": activityLevel,
|
||||
};
|
||||
}
|
||||
|
||||
factory UserProfileDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserProfileDto(
|
||||
id: json["id"] ?? 0,
|
||||
name: json["name"] ?? "",
|
||||
email: json["email"] ?? "",
|
||||
avatar: json["avatar"] ?? "",
|
||||
ageRange: json["age_range"] ?? "",
|
||||
foodAllergiesList: (json["food_allergies"] as List?)?.cast<String>() ?? [],
|
||||
dietaryPreferencesList: (json["dietary_preferences"] as List?)?.cast<String>() ?? [],
|
||||
medicalInformationList: (json["medical_information"] as List?)?.cast<String>() ?? [],
|
||||
currentMedicationsList: (json["current_medications"] as List?)?.cast<String>() ?? [],
|
||||
activityLevel: json["activity_level"] ?? "",
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user