feat: 유산 목록에서 로그를 더 가져올 수 있음

This commit is contained in:
2022-06-25 12:22:25 +09:00
parent da2a6f347a
commit 647c2439e3
5 changed files with 325 additions and 255 deletions
@@ -0,0 +1,40 @@
<?php
namespace sammo\API\InheritAction;
use DateTimeInterface;
use sammo\DB;
use sammo\Session;
use sammo\Validator;
use sammo\Util;
class GetMoreLog extends \sammo\BaseAPI
{
public function validateArgs(): ?string
{
$v = new Validator($this->args);
$v->rule('integer', 'lastID');
if (!$v->validate()) {
return $v->errorStr();
}
$this->args['lastID'] = Util::toInt($this->args['lastID']);
return null;
}
function getRequiredSessionMode(): int
{
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
}
function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
{
$userID = $session->userID;
$lastID = $this->args['lastID'];
$db = DB::db();
$lastInheritPointLogs = $db->query('SELECT id, server_id, year, month, date, text FROM user_record WHERE log_type = %s AND `user_id` = %i AND id < %i ORDER BY id desc LIMIT 30', "inheritPoint", $userID, $lastID);
return [
'result'=> true,
'log' => $lastInheritPointLogs,
];
}
}