123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import 'package:domain/constants/api_constants.dart';
- import 'package:domain/entity/server_time.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 'package:shared/utils/util.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'package:plugin_basic/provider/http_provider/http_provider.dart';
- import 'property_ioan_state.dart';
- part 'property_ioan_repository.g.dart';
- @Riverpod(keepAlive: true)
- PropertyIoanRepository propertyIoanRepository(Ref ref) {
- final dioEngine = ref.watch(dioEngineProvider);
- return PropertyIoanRepository(dioEngine: dioEngine);
- }
- /*
- * 数据仓库
- */
- class PropertyIoanRepository {
- DioEngine dioEngine;
- PropertyIoanRepository({required this.dioEngine});
- Future<HttpResult<Object>> fetchPropertyIoanList(
- Map<String, dynamic>? data, {
- CancelToken? cancelToken,
- }) async {
- Map<String, dynamic> params = {};
- // if (!Utils.isEmpty(type)) {
- // params["type"] = type!;
- // }
- params = data!;
- Map<String, String> headers = {};
- headers["Content-Type"] = "application/x-www-form-urlencoded";
- headers["Accept"] = "application/x.yyjobs-api.v1+json";
- final result = await dioEngine.requestNetResult(
- // ApiConstants.apiServerTime, // api 地址
- '/index.php/api/employee/extra/time', // api 地址
- params: params,
- headers: headers,
- method: HttpMethod.GET,
- isShowLoadingDialog: true, //是否展示默认的Loading弹窗
- networkDebounce: true, //是否防抖防止重复请求
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = PropertyIoanState.fromMap(json!);
- //重新赋值data或list
- return result.convert<PropertyIoanState>(data: data);
- }
- return result.convert();
- }
- }
|