This commit is contained in:
2026-03-07 17:24:59 +08:00
parent 4418ebecac
commit b0ec8ab4bd
417 changed files with 42546 additions and 2 deletions

View 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是stringmood_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,
};
}