基本完成
This commit is contained in:
27
lib/api/endpoints/profile_api.dart
Normal file
27
lib/api/endpoints/profile_api.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user