fix: NPC 빙의 장수 목록 안보이는 버그 수정

- API/Global/GeneralList를 WithToken과 분리
This commit is contained in:
2022-04-20 22:33:46 +09:00
parent ec10949c64
commit 5eaafaeee6
5 changed files with 46 additions and 24 deletions
+3 -9
View File
@@ -1,6 +1,6 @@
<?php
namespace sammo\API\List\Nation;
namespace sammo\API\Global;
use sammo\DB;
use sammo\General;
@@ -27,14 +27,9 @@ use function sammo\increaseRefresh;
class GeneralList extends \sammo\BaseAPI
{
static $withToken = false;
public function validateArgs(): ?string
{
$v = new Validator($this->args);
$v
->rule('boolean', 'with_token');
if (!$v->validate()) {
return $v->errorStr();
}
return null;
}
@@ -46,7 +41,6 @@ class GeneralList extends \sammo\BaseAPI
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag)
{
$db = DB::db();
$withToken = $this->args['with_token']??false;
$gameStor = KVStorage::getStorage($db, 'game_env');
$userID = $session->userID;
@@ -148,7 +142,7 @@ class GeneralList extends \sammo\BaseAPI
];
if ($withToken) {
if (static::$withToken) {
$now = (new \DateTimeImmutable())->format('Y-m-d H:i:s');
$tokens = [];
foreach ($db->query('SELECT * FROM select_npc_token WHERE `valid_until`>=%s', $now) as $token) {
@@ -0,0 +1,31 @@
<?php
namespace sammo\API\Global;
use sammo\DB;
use sammo\General;
use sammo\Json;
use sammo\KVStorage;
use sammo\RootDB;
use sammo\Session;
use sammo\Util;
use sammo\Validator;
use function sammo\calcLeadershipBonus;
use function sammo\checkLimit;
use function sammo\checkSecretPermission;
use function sammo\getDed;
use function sammo\getDedLevelText;
use function sammo\getExpLevel;
use function sammo\getGenChar;
use function sammo\getGeneralSpecialDomesticName;
use function sammo\getGeneralSpecialWarName;
use function sammo\getHonor;
use function sammo\getNationStaticInfo;
use function sammo\getOfficerLevelText;
use function sammo\increaseRefresh;
class GeneralListWithToken extends GeneralList
{
static $withToken = true;
}
+2 -3
View File
@@ -50,9 +50,8 @@ const apiRealPath = {
Join: POST as APICallT<JoinArgs>,
},
Global: {
GeneralList: GET as APICallT<{
with_token?: boolean
}, GeneralListResponse>,
GeneralList: GET as APICallT<undefined, GeneralListResponse>,
GeneralListWithToken: GET as APICallT<undefined, GeneralListResponse>,
GetConst: GET as APICallT<undefined, GetConstResponse>,
GetHistory: StrVar('serverID')(
NumVar('year',
+4 -6
View File
@@ -101,9 +101,9 @@ const templateGeneralRow =
<td><%specialDomesticWithTooltip%> / <%specialWarWithTooltip%></td>\
<td>Lv <%explevel%></td>\
<td><%nation%></td>\
<td><%experience%></td>\
<td><%dedication%></td>\
<td><%officerLevel%></td>\
<td><%experienceStr%></td>\
<td><%dedicationStr%></td>\
<td><%officerLevelStr%></td>\
<td><%total%></td>\
<td><%leadership%></td>\
<td><%strength%></td>\
@@ -420,9 +420,7 @@ $(function ($) {
$('#btn_load_general_list').on('click', async function () {
try {
const result = await SammoAPI.Global.GeneralList({
with_token: true,
});
const result = await SammoAPI.Global.GeneralListWithToken();
printGeneralList(result);
} catch (e) {
console.error(e);
+6 -6
View File
@@ -5622,9 +5622,9 @@
"integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA=="
},
"node_modules/follow-redirects": {
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
"funding": [
{
"type": "individual",
@@ -14691,9 +14691,9 @@
"integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA=="
},
"follow-redirects": {
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA=="
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
},
"fraction.js": {
"version": "4.1.2",