123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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<HttpResult<VerifyCode>> 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<VerifyCode>(data: data);
- }
- return result.convert<VerifyCode>();
- }
- /// 获取用户详情数据
- Future<HttpResult<UserProfile>> 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<UserProfile>(data: data);
- }
- return result.convert();
- }
- }
|