54 lines
1.2 KiB
Dart
54 lines
1.2 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'common.g.dart';
|
|
|
|
@JsonSerializable(genericArgumentFactories: true)
|
|
class PageResult<T> {
|
|
@JsonKey(name: 'records')
|
|
final List<T> records;
|
|
|
|
@JsonKey(name: 'total')
|
|
final int total;
|
|
|
|
@JsonKey(name: 'size')
|
|
final int size;
|
|
|
|
@JsonKey(name: 'current')
|
|
final int current;
|
|
|
|
@JsonKey(name: 'pages')
|
|
final int pages;
|
|
|
|
const PageResult({
|
|
required this.records,
|
|
required this.total,
|
|
required this.size,
|
|
required this.current,
|
|
required this.pages,
|
|
});
|
|
|
|
factory PageResult.fromJson(
|
|
Map<String, dynamic> json,
|
|
T Function(Object? json) fromJsonT,
|
|
) => _$PageResultFromJson(json, fromJsonT);
|
|
|
|
Map<String, dynamic> toJson(Object? Function(T value) toJsonT) =>
|
|
_$PageResultToJson(this, toJsonT);
|
|
}
|
|
|
|
@JsonSerializable(genericArgumentFactories: true)
|
|
class ChartData {
|
|
@JsonKey(name: 'name')
|
|
final String name;
|
|
|
|
@JsonKey(name: 'value')
|
|
final double value;
|
|
|
|
const ChartData({required this.name, required this.value});
|
|
|
|
factory ChartData.fromJson(Map<String, dynamic> json) =>
|
|
_$ChartDataFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$ChartDataToJson(this);
|
|
}
|