110 lines
2.3 KiB
Dart
110 lines
2.3 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);
|
|
}
|
|
|
|
@JsonSerializable(genericArgumentFactories: true)
|
|
class BlogStats {
|
|
@JsonKey(name: 'blogCount')
|
|
final int blogCount;
|
|
|
|
@JsonKey(name: 'categoryCount')
|
|
final int categoryCount;
|
|
|
|
@JsonKey(name: 'greatCount')
|
|
final int greatCount;
|
|
|
|
@JsonKey(name: 'visitCount')
|
|
final int visitCount;
|
|
|
|
@JsonKey(name: 'wordCount')
|
|
final int wordCount;
|
|
|
|
const BlogStats({
|
|
required this.blogCount,
|
|
required this.categoryCount,
|
|
required this.greatCount,
|
|
required this.visitCount,
|
|
required this.wordCount,
|
|
});
|
|
|
|
factory BlogStats.fromJson(Map<String, dynamic> json) =>
|
|
_$BlogStatsFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$BlogStatsToJson(this);
|
|
}
|