v1.0.1
This commit is contained in:
46
lib/models/news/news_banner_model.dart
Normal file
46
lib/models/news/news_banner_model.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NewsBannerModel {
|
||||
NewsBannerModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.picUrl,
|
||||
this.objectId,
|
||||
this.objectUrl,
|
||||
});
|
||||
|
||||
factory NewsBannerModel.fromJson(Map<String, dynamic> json) =>
|
||||
NewsBannerModel(
|
||||
id: asT<int>(json['id'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
picUrl: asT<String>(json['pic_url'])!,
|
||||
objectId: asT<int?>(json['object_id']),
|
||||
objectUrl: asT<String?>(json['object_url']),
|
||||
);
|
||||
|
||||
int id;
|
||||
String title;
|
||||
String picUrl;
|
||||
int? objectId;
|
||||
String? objectUrl;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'title': title,
|
||||
'pic_url': picUrl,
|
||||
'object_id': objectId,
|
||||
'object_url': objectUrl,
|
||||
};
|
||||
}
|
||||
74
lib/models/news/news_list_item_model.dart
Normal file
74
lib/models/news/news_list_item_model.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NewsListItemModel {
|
||||
NewsListItemModel({
|
||||
required this.articleId,
|
||||
required this.title,
|
||||
this.createTime,
|
||||
this.intro,
|
||||
this.authorId,
|
||||
this.status,
|
||||
this.rowPicUrl,
|
||||
this.colPicUrl,
|
||||
this.pageUrl,
|
||||
this.authorUid,
|
||||
this.cover,
|
||||
this.nickname,
|
||||
});
|
||||
|
||||
factory NewsListItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
NewsListItemModel(
|
||||
articleId: asT<int>(json['article_id'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
createTime: asT<int?>(json['create_time']),
|
||||
intro: asT<String?>(json['intro']),
|
||||
authorId: asT<int?>(json['author_id']),
|
||||
status: asT<int?>(json['status']),
|
||||
rowPicUrl: asT<String?>(json['row_pic_url']),
|
||||
colPicUrl: asT<String?>(json['col_pic_url']),
|
||||
pageUrl: asT<String?>(json['page_url']),
|
||||
authorUid: asT<int?>(json['author_uid']),
|
||||
cover: asT<String?>(json['cover']),
|
||||
nickname: asT<String?>(json['nickname']),
|
||||
);
|
||||
|
||||
int articleId;
|
||||
String title;
|
||||
int? createTime;
|
||||
String? intro;
|
||||
int? authorId;
|
||||
int? status;
|
||||
String? rowPicUrl;
|
||||
String? colPicUrl;
|
||||
String? pageUrl;
|
||||
int? authorUid;
|
||||
String? cover;
|
||||
String? nickname;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'article_id': articleId,
|
||||
'title': title,
|
||||
'create_time': createTime,
|
||||
'intro': intro,
|
||||
'author_id': authorId,
|
||||
'status': status,
|
||||
'row_pic_url': rowPicUrl,
|
||||
'col_pic_url': colPicUrl,
|
||||
'page_url': pageUrl,
|
||||
'author_uid': authorUid,
|
||||
'cover': cover,
|
||||
'nickname': nickname,
|
||||
};
|
||||
}
|
||||
42
lib/models/news/news_stat_model.dart
Normal file
42
lib/models/news/news_stat_model.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NewsStatModel {
|
||||
NewsStatModel({
|
||||
required this.commentAmount,
|
||||
required this.moodAmount,
|
||||
required this.rowPicUrl,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
factory NewsStatModel.fromJson(Map<String, dynamic> json) => NewsStatModel(
|
||||
/// DMZJ后端是真混乱... commentAmount是string,mood_amount是int
|
||||
commentAmount: int.tryParse(json['comment_amount'].toString()) ?? 0,
|
||||
moodAmount: int.tryParse(json['mood_amount'].toString()) ?? 0,
|
||||
rowPicUrl: asT<String>(json['row_pic_url'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
);
|
||||
|
||||
int commentAmount;
|
||||
int moodAmount;
|
||||
String rowPicUrl;
|
||||
String title;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'comment_amount': commentAmount,
|
||||
'mood_amount': moodAmount,
|
||||
'row_pic_url': rowPicUrl,
|
||||
'title': title,
|
||||
};
|
||||
}
|
||||
33
lib/models/news/news_tag_model.dart
Normal file
33
lib/models/news/news_tag_model.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NewsTagModel {
|
||||
NewsTagModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
factory NewsTagModel.fromJson(Map<String, dynamic> json) => NewsTagModel(
|
||||
id: asT<int>(json['id'])!,
|
||||
name: asT<String>(json['name'])!,
|
||||
);
|
||||
|
||||
int id;
|
||||
String name;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user