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},
|
queryParameters: {'page': page, 'pageSize': pageSize},
|
||||||
);
|
);
|
||||||
final data = response.data;
|
final data = response.data;
|
||||||
final items = (data['items'] as List? ?? data['records'] as List? ?? [])
|
// mining-service 返回格式: { data: [...], total: ... }
|
||||||
.map((json) => MiningRecordModel.fromJson(json))
|
final rawItems = data['data'] as List? ?? data['items'] as List? ?? data['records'] as List? ?? [];
|
||||||
.toList();
|
final items = rawItems.map((json) => MiningRecordModel.fromJson({
|
||||||
final pagination = data['pagination'] ?? {};
|
'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(
|
return MiningRecordsPage(
|
||||||
items: items,
|
items: items,
|
||||||
total: pagination['total'] ?? items.length,
|
total: total,
|
||||||
page: pagination['page'] ?? page,
|
page: page,
|
||||||
pageSize: pagination['pageSize'] ?? pageSize,
|
pageSize: pageSize,
|
||||||
totalPages: pagination['totalPages'] ?? 1,
|
totalPages: (total / pageSize).ceil(),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw ServerException(e.toString());
|
throw ServerException(e.toString());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue