import 'dart:typed_data'; import 'package:domain/entity/payment_page_entity.dart'; import 'package:plugin_platform/platform_export.dart'; import 'package:plugin_platform/http/dio_engine.dart'; import 'package:plugin_platform/http/http_result.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import '../constants/api_constants.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:plugin_basic/provider/http_provider/http_provider.dart'; part 'payment_repository.g.dart'; @Riverpod(keepAlive: true) PaymentRepository paymentRepository(Ref ref) { final dioEngine = ref.watch(dioEngineProvider); return PaymentRepository(dioEngine: dioEngine); } /* * 支付模块的数据仓库 */ class PaymentRepository { DioEngine dioEngine; PaymentRepository({required this.dioEngine}); /// 获取支付列表 Future> fetchPaymentList({ required String type, required int curPage, CancelToken? cancelToken, }) async { Map params = {}; params['type'] = type; params['page'] = curPage.toString(); params['limit'] = "10"; final result = await dioEngine.requestNetResult( ApiConstants.apiPaymentList, params: params, method: HttpMethod.GET, cancelToken: cancelToken, ); if (result.isSuccess) { final json = result.getDataJson(); var data = PaymentPageEntity.fromJson(json!); return result.convert(data: data); } return result.convert(); } }