28 lines
1.0 KiB
Dart
28 lines
1.0 KiB
Dart
import 'package:food_health/api/dto/profile_options_dto.dart';
|
|
import 'package:food_health/api/dto/user_profile_dto.dart';
|
|
import 'package:food_health/api/network/request.dart';
|
|
|
|
///获取用户档案
|
|
Future<UserProfileDto> getUserProfileApi() async {
|
|
var res = await Request().get("/user/profile");
|
|
return UserProfileDto.fromJson(res);
|
|
}
|
|
|
|
///获取档案选项
|
|
Future<List<ProfileOptionDto>> getProfileOptionsApi() async {
|
|
var res = await Request().get("/user/get_user_profile_options");
|
|
return (res as List).map((e) => ProfileOptionDto.fromJson(e)).toList();
|
|
}
|
|
|
|
///更新档案
|
|
Future<void> updateProfileApi(UserProfileDto userProfile) async {
|
|
await Request().post("/user/update_profile", {
|
|
"age_range": userProfile.ageRange,
|
|
"food_allergies": userProfile.foodAllergiesList,
|
|
"dietary_preferences": userProfile.dietaryPreferencesList,
|
|
"medical_information": userProfile.medicalInformationList,
|
|
"current_medications": userProfile.currentMedicationsList,
|
|
"activity_level": userProfile.activityLevel,
|
|
});
|
|
}
|