import 'package:dio/dio.dart'; import '../core/api/api_client.dart'; import '../core/exceptions.dart'; import '../core/models/page_result.dart'; import '../models/finance.dart'; class FinanceRepository { final ApiClient _client; const FinanceRepository(this._client); Future> listRecords({ String? type, String? month, int page = 1, int pageSize = 50, }) async { try { final params = { 'page': page, 'page_size': pageSize, if (type != null && type.isNotEmpty) 'type': type, if (month != null && month.isNotEmpty) 'month': month, }; final resp = await _client.get('/finance/records', params: params); return PageResult.fromJson( resp.data as Map, FinanceRecord.fromJson, ); } on DioException catch (e) { throw AppException( e.response?.data?['error'] as String? ?? '获取财务记录失败', statusCode: e.response?.statusCode, ); } } }