79 lines
1.6 KiB
Dart
79 lines
1.6 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
// flutter pub run build_runner build
|
|
part 'blog.g.dart';
|
|
|
|
@JsonSerializable()
|
|
class Blog {
|
|
@JsonKey(name: 'id')
|
|
final int id;
|
|
|
|
@JsonKey(name: 'title')
|
|
final String title;
|
|
|
|
@JsonKey(name: 'topValue')
|
|
final int topValue;
|
|
|
|
@JsonKey(name: 'isGreat')
|
|
final bool isGreat;
|
|
|
|
@JsonKey(name: 'category')
|
|
final String category;
|
|
|
|
@JsonKey(name: 'summary')
|
|
final String summary;
|
|
|
|
@JsonKey(name: 'content')
|
|
final String? content;
|
|
|
|
@JsonKey(name: 'wordCount')
|
|
final int wordCount;
|
|
|
|
@JsonKey(name: 'readDuration')
|
|
final int readDuration;
|
|
|
|
@JsonKey(name: 'visitCount')
|
|
final int visitCount;
|
|
|
|
@JsonKey(name: 'createTime')
|
|
final String createTime;
|
|
|
|
@JsonKey(name: 'updateTime')
|
|
final String updateTime;
|
|
|
|
Blog({
|
|
required this.id,
|
|
required this.title,
|
|
required this.topValue,
|
|
required this.isGreat,
|
|
required this.category,
|
|
required this.summary,
|
|
this.content,
|
|
required this.wordCount,
|
|
required this.readDuration,
|
|
required this.visitCount,
|
|
required this.createTime,
|
|
required this.updateTime,
|
|
});
|
|
|
|
factory Blog.fromJson(Map<String, dynamic> json) => _$BlogFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$BlogToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class BlogCategory {
|
|
@JsonKey(name: 'name')
|
|
final String name;
|
|
|
|
@JsonKey(name: 'count')
|
|
final int count;
|
|
|
|
BlogCategory({required this.name, required this.count});
|
|
|
|
factory BlogCategory.fromJson(Map<String, dynamic> json) =>
|
|
_$BlogCategoryFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$BlogCategoryToJson(this);
|
|
}
|