refac: 변경한 DTO에 따라 코드 수정
- Spatie/DataTransferObject 대비
- MapFrom,MapTo -> RawName
- Strict -> 항상
- 심지어 raw type도 더 까다롭게
- array에 MapConverter 적용
- NullIsUndefined 적용
- 빈 nullable arg자리에 null 강제 지정
- Vue3에 v-model.number 지정
- input type="number" 기준
This commit is contained in:
@@ -47,7 +47,7 @@ class GetBettingDetail extends \sammo\BaseAPI
|
||||
}
|
||||
|
||||
try{
|
||||
$bettingInfo = new BettingInfo($rawBettingInfo);
|
||||
$bettingInfo = BettingInfo::fromArray($rawBettingInfo);
|
||||
}
|
||||
catch(\Error $e){
|
||||
return $e->getMessage();
|
||||
|
||||
@@ -49,7 +49,7 @@ class GetBettingList extends \sammo\BaseAPI
|
||||
|
||||
$bettingList = [];
|
||||
foreach ($bettingStor->getAll() as $_key => $rawItem) {
|
||||
$item = new BettingInfo($rawItem);
|
||||
$item = BettingInfo::fromArray($rawItem);
|
||||
if ($reqType !== null && $item->type != $reqType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class AddComment extends \sammo\BaseAPI
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
$this->args['voteID'] = (int)$this->args['voteID'];
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -46,11 +47,12 @@ class AddComment extends \sammo\BaseAPI
|
||||
|
||||
|
||||
$comment = new VoteComment(
|
||||
vote_id: $voteID,
|
||||
general_id: $generalID,
|
||||
nation_id: $nationID,
|
||||
nation_name: $nationName,
|
||||
general_name: $generalName,
|
||||
id: null,
|
||||
voteID: $voteID,
|
||||
generalID: $generalID,
|
||||
nationID: $nationID,
|
||||
nationName: $nationName,
|
||||
generalName: $generalName,
|
||||
text: $text,
|
||||
date: $date
|
||||
);
|
||||
|
||||
@@ -40,7 +40,7 @@ class GetVoteDetail extends \sammo\BaseAPI
|
||||
if (!$rawVote) {
|
||||
return '설문조사가 없습니다.';
|
||||
}
|
||||
$voteInfo = new VoteInfo(...$rawVote);
|
||||
$voteInfo = VoteInfo::fromArray($rawVote);
|
||||
|
||||
|
||||
$votes = array_map(fn ($arr) => [Json::decode($arr[0]), $arr[1]], $db->queryAllLists(
|
||||
@@ -48,13 +48,13 @@ class GetVoteDetail extends \sammo\BaseAPI
|
||||
$voteID
|
||||
));
|
||||
|
||||
$comments = VoteComment::arrayOf($db->query('SELECT * FROM vote_comment WHERE vote_id = %i ORDER BY `id` ASC', $voteID));
|
||||
$comments = array_map(fn ($arr) => VoteComment::fromArray($arr), $db->query('SELECT * FROM vote_comment WHERE vote_id = %i ORDER BY `id` ASC', $voteID));
|
||||
|
||||
$myVote = null;
|
||||
if($session->isGameLoggedIn()){
|
||||
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){
|
||||
if ($rawMyVote) {
|
||||
$myVote = Json::decode($rawMyVote);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class GetVoteList extends \sammo\BaseAPI
|
||||
continue;
|
||||
}
|
||||
$voteID = (int)substr($voteKey, 5);
|
||||
$votes[$voteID] = new VoteInfo(...$rawVote);
|
||||
$votes[$voteID] = VoteInfo::fromArray($rawVote);
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -43,7 +43,7 @@ class NewVote extends \sammo\BaseAPI
|
||||
if (!$rawLastVoteInfo) {
|
||||
return;
|
||||
}
|
||||
$lastVoteInfo = new VoteInfo(...$rawLastVoteInfo);
|
||||
$lastVoteInfo = VoteInfo::fromArray($rawLastVoteInfo);
|
||||
if ($lastVoteInfo->endDate) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class Vote extends \sammo\BaseAPI
|
||||
if (!$rawVoteInfo) {
|
||||
return '설문조사가 없습니다.';
|
||||
}
|
||||
$voteInfo = new VoteInfo(...$rawVoteInfo);
|
||||
$voteInfo = VoteInfo::fromArray($rawVoteInfo);
|
||||
|
||||
if ($voteInfo->endDate && $voteInfo->endDate < new \DateTimeImmutable()) {
|
||||
return '설문조사가 종료되었습니다.';
|
||||
|
||||
Reference in New Issue
Block a user