fix(mining-app): fix mining records data parsing from mining-service
Map miningMinute->distributionMinute, minedAmount->shareAmount, secondDistribution->priceSnapshot to match entity fields Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
12f8fa67fc
commit
8ae9e217ff
|
|
@ -49,16 +49,24 @@ class MiningRemoteDataSourceImpl implements MiningRemoteDataSource {
|
|||
queryParameters: {'page': page, 'pageSize': pageSize},
|
||||
);
|
||||
final data = response.data;
|
||||
final items = (data['items'] as List? ?? data['records'] as List? ?? [])
|
||||
.map((json) => MiningRecordModel.fromJson(json))
|
||||
.toList();
|
||||
final pagination = data['pagination'] ?? {};
|
||||
// mining-service 返回格式: { data: [...], total: ... }
|
||||
final rawItems = data['data'] as List? ?? data['items'] as List? ?? data['records'] as List? ?? [];
|
||||
final items = rawItems.map((json) => MiningRecordModel.fromJson({
|
||||
'id': json['id']?.toString() ?? '',
|
||||
'accountSequence': accountSequence,
|
||||
'distributionMinute': json['miningMinute']?.toString() ?? json['distributionMinute'] ?? '',
|
||||
'contributionRatio': json['contributionRatio']?.toString() ?? '0',
|
||||
'shareAmount': json['minedAmount']?.toString() ?? json['shareAmount'] ?? '0',
|
||||
'priceSnapshot': json['secondDistribution']?.toString() ?? json['priceSnapshot'] ?? '0',
|
||||
'createdAt': json['createdAt'],
|
||||
})).toList();
|
||||
final total = data['total'] ?? items.length;
|
||||
return MiningRecordsPage(
|
||||
items: items,
|
||||
total: pagination['total'] ?? items.length,
|
||||
page: pagination['page'] ?? page,
|
||||
pageSize: pagination['pageSize'] ?? pageSize,
|
||||
totalPages: pagination['totalPages'] ?? 1,
|
||||
total: total,
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
totalPages: (total / pageSize).ceil(),
|
||||
);
|
||||
} catch (e) {
|
||||
throw ServerException(e.toString());
|
||||
|
|
|
|||
Loading…
Reference in New Issue