feat: vote pabel (#807)

This commit is contained in:
My-Responsitories
2025-05-04 13:53:00 +08:00
committed by GitHub
parent 9b3c3efb09
commit 2cfad80214
9 changed files with 755 additions and 300 deletions

View File

@@ -1,3 +1,5 @@
import 'package:PiliPlus/models/dynamics/vote_model.dart';
class ArticleContentModel {
int? align;
int? paraType;
@@ -188,7 +190,7 @@ class Card {
Common? common;
Live? live;
Opus? opus;
Vote? vote;
SimpleVoteInfo? vote;
Music? music;
Goods? goods;
@@ -201,7 +203,7 @@ class Card {
common = json['common'] == null ? null : Common.fromJson(json['common']);
live = json['live'] == null ? null : Live.fromJson(json['live']);
opus = json['opus'] == null ? null : Opus.fromJson(json['opus']);
vote = json['vote'] == null ? null : Vote.fromJson(json['vote']);
vote = json['vote'] == null ? null : SimpleVoteInfo.fromJson(json['vote']);
music = json['music'] == null ? null : Music.fromJson(json['music']);
goods = json['goods'] == null ? null : Goods.fromJson(json['goods']);
}
@@ -259,28 +261,6 @@ class Music {
}
}
class Vote {
int? choiceCnt;
int? defaultShare;
String? desc;
int? endTime;
int? status;
int? uid;
int? voteId;
late int joinNum;
Vote.fromJson(Map<String, dynamic> json) {
choiceCnt = json['choice_cnt'];
defaultShare = json['default_share'];
desc = json['desc'];
endTime = json['end_time'];
status = json['status'];
uid = json['uid'];
voteId = json['vote_id'];
joinNum = json['join_num'] ?? 0;
}
}
class Opus {
int? authorMid;
String? authorName;

View File

@@ -0,0 +1,63 @@
class SimpleVoteInfo {
int? choiceCnt;
int? defaultShare;
String? desc;
int? endTime;
int? status;
int? uid;
int? voteId;
late int joinNum;
SimpleVoteInfo.fromJson(Map<String, dynamic> json) {
choiceCnt = json['choice_cnt'];
defaultShare = json['default_share'];
desc = json['desc'];
endTime = json['end_time'];
status = json['status'];
uid = json['uid'];
voteId = json['vote_id'];
joinNum = json['join_num'] ?? 0;
}
}
class VoteInfo extends SimpleVoteInfo {
String? title;
int? ctime;
List<int>? myVotes;
late List<Option> options;
int? optionsCnt;
int? voterLevel;
String? face;
String? name;
VoteInfo.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
title = json['title'];
uid = json['vote_publisher'];
ctime = json['ctime'];
myVotes = (json['my_votes'] as List?)?.cast(); // doVote
options =
(json['options'] as List?)?.map((v) => Option.fromJson(v)).toList() ??
[];
optionsCnt = json['options_cnt'];
voterLevel = json['voter_level'];
face = json['face'];
name = json['name'];
}
factory VoteInfo.fromSeparatedJson(Map<String, dynamic> json) {
return VoteInfo.fromJson(json['vote_info'])
..myVotes = (json['my_votes'] as List?)?.cast(); // voteInfo
}
}
class Option {
int? optidx;
String? optdesc;
late int cnt;
Option.fromJson(Map<String, dynamic> json) {
optidx = json['opt_idx'];
optdesc = json['opt_desc'];
cnt = json['cnt'] ?? 0;
}
}