初始化
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/// 评论区置顶 Banner(GET /banner/list?scene=COMMENT_TOP)
|
||||
class CommentTopBannerModel {
|
||||
String? id;
|
||||
String? imageUrl;
|
||||
String? mediaType; // IMAGE | GIF
|
||||
String? linkType; // INTERNAL | EXTERNAL | NONE
|
||||
String? linkValue;
|
||||
int? sort;
|
||||
|
||||
CommentTopBannerModel({
|
||||
this.id,
|
||||
this.imageUrl,
|
||||
this.mediaType,
|
||||
this.linkType,
|
||||
this.linkValue,
|
||||
this.sort,
|
||||
});
|
||||
|
||||
bool get hasLink {
|
||||
final t = linkType?.toUpperCase();
|
||||
return t == 'INTERNAL' || t == 'EXTERNAL';
|
||||
}
|
||||
|
||||
bool get isGif =>
|
||||
mediaType?.toUpperCase() == 'GIF' || (imageUrl?.toLowerCase().contains('.gif') ?? false);
|
||||
|
||||
factory CommentTopBannerModel.fromJson(Map<String, dynamic>? json) {
|
||||
json ??= {};
|
||||
return CommentTopBannerModel(
|
||||
id: json['id']?.toString(),
|
||||
imageUrl: json['imageUrl']?.toString(),
|
||||
mediaType: json['mediaType']?.toString(),
|
||||
linkType: json['linkType']?.toString(),
|
||||
linkValue: json['linkValue']?.toString(),
|
||||
sort: json['sort'] is int ? json['sort'] as int : int.tryParse('${json['sort'] ?? ''}'),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user