import 'package:get/get.dart'; import 'package:plugin_platform/http/http_provider.dart'; import 'package:plugin_platform/http/http_result.dart'; import '../constants/api_constants.dart'; import '../entity/response/user_profile.dart'; import '../entity/response/verify_code.dart'; /// 用户相关 class AuthRepository extends GetxService { HttpProvider httpProvider; AuthRepository({required this.httpProvider}); /// 获取发送验证码的图片,用于发送短信 Future> getVerifyCodeImage() async { //Get请求 final result = await httpProvider.requestNetResult(ApiConstants.apiVerifyCodeImage); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { final json = result.getDataJson(); var data = VerifyCode.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// 获取用户详情数据 Future> fetchUserProfile() async { //POST请求 final result = await httpProvider.requestNetResult( ApiConstants.apiUserProfile, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UserProfile.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } }