feat:增加博客卡片内容
This commit is contained in:
62
lib/models/blog.dart
Normal file
62
lib/models/blog.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
}
|
||||
37
lib/models/blog.g.dart
Normal file
37
lib/models/blog.g.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'blog.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Blog _$BlogFromJson(Map<String, dynamic> json) => Blog(
|
||||
id: (json['id'] as num).toInt(),
|
||||
title: json['title'] as String,
|
||||
topValue: (json['topValue'] as num).toInt(),
|
||||
isGreat: json['isGreat'] as bool,
|
||||
category: json['category'] as String,
|
||||
summary: json['summary'] as String,
|
||||
content: json['content'] as String?,
|
||||
wordCount: (json['wordCount'] as num).toInt(),
|
||||
readDuration: (json['readDuration'] as num).toInt(),
|
||||
visitCount: (json['visitCount'] as num).toInt(),
|
||||
createTime: json['createTime'] as String,
|
||||
updateTime: json['updateTime'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BlogToJson(Blog instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'topValue': instance.topValue,
|
||||
'isGreat': instance.isGreat,
|
||||
'category': instance.category,
|
||||
'summary': instance.summary,
|
||||
'content': instance.content,
|
||||
'wordCount': instance.wordCount,
|
||||
'readDuration': instance.readDuration,
|
||||
'visitCount': instance.visitCount,
|
||||
'createTime': instance.createTime,
|
||||
'updateTime': instance.updateTime,
|
||||
};
|
||||
37
lib/models/common.dart
Normal file
37
lib/models/common.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
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);
|
||||
}
|
||||
29
lib/models/common.g.dart
Normal file
29
lib/models/common.g.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'common.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PageResult<T> _$PageResultFromJson<T>(
|
||||
Map<String, dynamic> json,
|
||||
T Function(Object? json) fromJsonT,
|
||||
) => PageResult<T>(
|
||||
records: (json['records'] as List<dynamic>).map(fromJsonT).toList(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
size: (json['size'] as num).toInt(),
|
||||
current: (json['current'] as num).toInt(),
|
||||
pages: (json['pages'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PageResultToJson<T>(
|
||||
PageResult<T> instance,
|
||||
Object? Function(T value) toJsonT,
|
||||
) => <String, dynamic>{
|
||||
'records': instance.records.map(toJsonT).toList(),
|
||||
'total': instance.total,
|
||||
'size': instance.size,
|
||||
'current': instance.current,
|
||||
'pages': instance.pages,
|
||||
};
|
||||
Reference in New Issue
Block a user