v1.0.1
This commit is contained in:
58
lib/models/comment/comment_item.dart
Normal file
58
lib/models/comment/comment_item.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
/// 动漫之家评论接口太TM混乱了
|
||||
/// 使用此类统一Model
|
||||
|
||||
class CommentItem {
|
||||
CommentItem({
|
||||
required this.id,
|
||||
required this.objId,
|
||||
required this.content,
|
||||
required this.photo,
|
||||
required this.createTime,
|
||||
required this.images,
|
||||
required this.likeAmount,
|
||||
required this.nickname,
|
||||
required this.replyAmount,
|
||||
required this.userId,
|
||||
required this.gender,
|
||||
required this.type,
|
||||
required this.originId,
|
||||
this.isEmpty = false,
|
||||
});
|
||||
|
||||
factory CommentItem.createEmpty() {
|
||||
return CommentItem(
|
||||
id: 0,
|
||||
objId: 0,
|
||||
content: "该评论不存在,可能已被删除",
|
||||
photo: "",
|
||||
createTime: 0,
|
||||
images: [],
|
||||
likeAmount: 0.obs,
|
||||
nickname: "-",
|
||||
replyAmount: 0,
|
||||
userId: 0,
|
||||
gender: 0,
|
||||
type: 0,
|
||||
originId: 0,
|
||||
isEmpty: true,
|
||||
);
|
||||
}
|
||||
|
||||
int id;
|
||||
int objId;
|
||||
String content;
|
||||
int createTime;
|
||||
Rx<int> likeAmount;
|
||||
int replyAmount;
|
||||
String nickname;
|
||||
String photo;
|
||||
List<String> images;
|
||||
int userId;
|
||||
List<CommentItem> parents = [];
|
||||
bool isEmpty;
|
||||
int gender;
|
||||
int type;
|
||||
int originId;
|
||||
}
|
||||
123
lib/models/comment/user_comment_item.dart
Normal file
123
lib/models/comment/user_comment_item.dart
Normal file
@@ -0,0 +1,123 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class UserCommentItem {
|
||||
UserCommentItem({
|
||||
required this.commentId,
|
||||
required this.content,
|
||||
required this.replyAmount,
|
||||
required this.likeAmount,
|
||||
this.originCommentId,
|
||||
required this.objId,
|
||||
required this.createTime,
|
||||
this.toCommentId,
|
||||
required this.objCover,
|
||||
required this.objName,
|
||||
this.pageUrl,
|
||||
this.mastercomment,
|
||||
});
|
||||
|
||||
factory UserCommentItem.fromJson(Map<String, dynamic> json) =>
|
||||
UserCommentItem(
|
||||
commentId: asT<int>(json['comment_id']) ?? 0,
|
||||
content: asT<String>(json['content']) ?? '',
|
||||
replyAmount: asT<int>(json['reply_amount']) ?? 0,
|
||||
likeAmount: asT<int>(json['like_amount']) ?? 0,
|
||||
originCommentId: asT<int?>(json['origin_comment_id']),
|
||||
objId: asT<int>(json['obj_id']) ?? 0,
|
||||
createTime: asT<int>(json['create_time']) ?? 0,
|
||||
toCommentId: asT<int?>(json['to_comment_id']),
|
||||
objCover: asT<String>(json['obj_cover']) ?? '',
|
||||
objName: asT<String>(json['obj_name']) ?? '',
|
||||
pageUrl: asT<String?>(json['page_url']),
|
||||
mastercomment: json['masterComment'] == null
|
||||
? null
|
||||
: UserMasterComment.fromJson(
|
||||
asT<Map<String, dynamic>>(json['masterComment'])!),
|
||||
);
|
||||
|
||||
int commentId;
|
||||
String content;
|
||||
int replyAmount;
|
||||
int likeAmount;
|
||||
int? originCommentId;
|
||||
int objId;
|
||||
int createTime;
|
||||
int? toCommentId;
|
||||
String objCover;
|
||||
String objName;
|
||||
String? pageUrl;
|
||||
UserMasterComment? mastercomment;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'comment_id': commentId,
|
||||
'content': content,
|
||||
'reply_amount': replyAmount,
|
||||
'like_amount': likeAmount,
|
||||
'origin_comment_id': originCommentId,
|
||||
'obj_id': objId,
|
||||
'create_time': createTime,
|
||||
'to_comment_id': toCommentId,
|
||||
'obj_cover': objCover,
|
||||
'obj_name': objName,
|
||||
'page_url': pageUrl,
|
||||
'masterComment': mastercomment,
|
||||
};
|
||||
}
|
||||
|
||||
class UserMasterComment {
|
||||
UserMasterComment({
|
||||
required this.id,
|
||||
required this.content,
|
||||
this.senderUid,
|
||||
this.likeAmount,
|
||||
required this.createTime,
|
||||
this.replyAmount,
|
||||
required this.nickname,
|
||||
});
|
||||
|
||||
factory UserMasterComment.fromJson(Map<String, dynamic> json) =>
|
||||
UserMasterComment(
|
||||
id: asT<int>(json['id'])!,
|
||||
content: asT<String>(json['content'])!,
|
||||
senderUid: asT<int?>(json['sender_uid']),
|
||||
likeAmount: asT<int?>(json['like_amount']),
|
||||
createTime: asT<int>(json['create_time'])!,
|
||||
replyAmount: asT<int?>(json['reply_amount']),
|
||||
nickname: asT<String>(json['nickname'])!,
|
||||
);
|
||||
|
||||
int id;
|
||||
String content;
|
||||
int? senderUid;
|
||||
int? likeAmount;
|
||||
int createTime;
|
||||
int? replyAmount;
|
||||
String nickname;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'content': content,
|
||||
'sender_uid': senderUid,
|
||||
'like_amount': likeAmount,
|
||||
'create_time': createTime,
|
||||
'reply_amount': replyAmount,
|
||||
'nickname': nickname,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user