mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-17 23:56:13 +08:00
feat: create vote (#871)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,6 +8,17 @@ class SimpleVoteInfo {
|
||||
int? voteId;
|
||||
late int joinNum;
|
||||
|
||||
SimpleVoteInfo({
|
||||
this.choiceCnt,
|
||||
this.defaultShare,
|
||||
this.desc,
|
||||
this.endTime,
|
||||
this.status,
|
||||
this.uid,
|
||||
this.voteId,
|
||||
this.joinNum = 0,
|
||||
});
|
||||
|
||||
SimpleVoteInfo.fromJson(Map<String, dynamic> json) {
|
||||
choiceCnt = json['choice_cnt'];
|
||||
defaultShare = json['default_share'];
|
||||
@@ -29,6 +40,34 @@ class VoteInfo extends SimpleVoteInfo {
|
||||
int? voterLevel;
|
||||
String? face;
|
||||
String? name;
|
||||
// 0 文字, 1 图片
|
||||
int? type;
|
||||
int? votePublisher;
|
||||
int? duration;
|
||||
int? onlyFansLevel;
|
||||
|
||||
VoteInfo({
|
||||
super.choiceCnt,
|
||||
super.defaultShare,
|
||||
super.desc,
|
||||
super.endTime,
|
||||
super.status,
|
||||
super.uid,
|
||||
super.voteId,
|
||||
super.joinNum = 0,
|
||||
this.title,
|
||||
this.ctime,
|
||||
this.myVotes,
|
||||
List<Option>? options,
|
||||
this.optionsCnt,
|
||||
this.voterLevel,
|
||||
this.face,
|
||||
this.name,
|
||||
this.type,
|
||||
this.votePublisher,
|
||||
this.duration,
|
||||
this.onlyFansLevel,
|
||||
}) : options = options ?? <Option>[];
|
||||
|
||||
VoteInfo.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
title = json['title'];
|
||||
@@ -42,22 +81,48 @@ class VoteInfo extends SimpleVoteInfo {
|
||||
voterLevel = json['voter_level'];
|
||||
face = json['face'];
|
||||
name = json['name'];
|
||||
type = json['type'];
|
||||
votePublisher = json['vote_publisher'];
|
||||
}
|
||||
|
||||
factory VoteInfo.fromSeparatedJson(Map<String, dynamic> json) {
|
||||
return VoteInfo.fromJson(json['vote_info'])
|
||||
..myVotes = (json['my_votes'] as List?)?.cast(); // voteInfo
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'title': title,
|
||||
'desc': desc,
|
||||
'type': type,
|
||||
'choice_cnt': choiceCnt,
|
||||
'duration': duration,
|
||||
'options': options.map((e) => e.toJson()).toList(),
|
||||
'only_fans_level': onlyFansLevel,
|
||||
'vote_publisher': votePublisher,
|
||||
if (voteId != null) 'vote_id': voteId,
|
||||
};
|
||||
}
|
||||
|
||||
class Option {
|
||||
int? optidx;
|
||||
String? optdesc;
|
||||
int? optIdx;
|
||||
String? optDesc;
|
||||
late int cnt;
|
||||
String? imgUrl;
|
||||
|
||||
Option({
|
||||
this.optDesc,
|
||||
this.imgUrl,
|
||||
});
|
||||
|
||||
Option.fromJson(Map<String, dynamic> json) {
|
||||
optidx = json['opt_idx'];
|
||||
optdesc = json['opt_desc'];
|
||||
optIdx = json['opt_idx'];
|
||||
optDesc = json['opt_desc'];
|
||||
cnt = json['cnt'] ?? 0;
|
||||
imgUrl = json['img_url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'opt_desc': optDesc,
|
||||
'img_url': imgUrl,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user