feat: 새 설문조사 모듈 UI

This commit is contained in:
2022-05-16 01:41:10 +09:00
parent 29228ed3bc
commit 42cca07419
13 changed files with 650 additions and 19 deletions
+17 -3
View File
@@ -44,17 +44,31 @@ class GetVoteDetail extends \sammo\BaseAPI
$votes = array_map(fn ($arr) => [Json::decode($arr[0]), $arr[1]], $db->queryAllLists(
'SELECT selection, count(*) AS cnt FROM vote_result WHERE voteID = %i GROUP BY selection',
'SELECT selection, count(*) AS cnt FROM vote WHERE vote_id = %i GROUP BY selection',
$voteID
));
$comments = VoteComment::arrayOf($db->query('SELECT * FROM vote_comment WHERE voteID = %i ORDER BY `id` ASC', $voteID));
$comments = VoteComment::arrayOf($db->query('SELECT * FROM vote_comment WHERE vote_id = %i ORDER BY `id` ASC', $voteID));
$myVote = null;
if($session->isGameLoggedIn()){
$generalID = $session->generalID;
$rawMyVote = $db->queryFirstField('SELECT selection FROM vote WHERE vote_id = %i AND general_id = %i', $voteID, $generalID);
if($rawMyVote){
$myVote = Json::decode($rawMyVote);
}
}
$userCnt = $db->queryFirstField('SELECT count(*) FROM general WHERE npc < 2');
return [
'result' => true,
'voteInfo' => $voteInfo,
'votes' => $votes,
'comments' => $comments
'comments' => $comments,
'myVote' => $myVote,
'userCnt' => $userCnt,
];
}
}