fix: NPC 빙의 장수 목록 안보이는 버그 수정
- API/Global/GeneralList를 WithToken과 분리
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\API\List\Nation;
|
namespace sammo\API\Global;
|
||||||
|
|
||||||
use sammo\DB;
|
use sammo\DB;
|
||||||
use sammo\General;
|
use sammo\General;
|
||||||
@@ -27,14 +27,9 @@ use function sammo\increaseRefresh;
|
|||||||
|
|
||||||
class GeneralList extends \sammo\BaseAPI
|
class GeneralList extends \sammo\BaseAPI
|
||||||
{
|
{
|
||||||
|
static $withToken = false;
|
||||||
public function validateArgs(): ?string
|
public function validateArgs(): ?string
|
||||||
{
|
{
|
||||||
$v = new Validator($this->args);
|
|
||||||
$v
|
|
||||||
->rule('boolean', 'with_token');
|
|
||||||
if (!$v->validate()) {
|
|
||||||
return $v->errorStr();
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +41,6 @@ class GeneralList extends \sammo\BaseAPI
|
|||||||
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag)
|
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$withToken = $this->args['with_token']??false;
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$userID = $session->userID;
|
$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');
|
$now = (new \DateTimeImmutable())->format('Y-m-d H:i:s');
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
foreach ($db->query('SELECT * FROM select_npc_token WHERE `valid_until`>=%s', $now) as $token) {
|
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
@@ -50,9 +50,8 @@ const apiRealPath = {
|
|||||||
Join: POST as APICallT<JoinArgs>,
|
Join: POST as APICallT<JoinArgs>,
|
||||||
},
|
},
|
||||||
Global: {
|
Global: {
|
||||||
GeneralList: GET as APICallT<{
|
GeneralList: GET as APICallT<undefined, GeneralListResponse>,
|
||||||
with_token?: boolean
|
GeneralListWithToken: GET as APICallT<undefined, GeneralListResponse>,
|
||||||
}, GeneralListResponse>,
|
|
||||||
GetConst: GET as APICallT<undefined, GetConstResponse>,
|
GetConst: GET as APICallT<undefined, GetConstResponse>,
|
||||||
GetHistory: StrVar('serverID')(
|
GetHistory: StrVar('serverID')(
|
||||||
NumVar('year',
|
NumVar('year',
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ const templateGeneralRow =
|
|||||||
<td><%specialDomesticWithTooltip%> / <%specialWarWithTooltip%></td>\
|
<td><%specialDomesticWithTooltip%> / <%specialWarWithTooltip%></td>\
|
||||||
<td>Lv <%explevel%></td>\
|
<td>Lv <%explevel%></td>\
|
||||||
<td><%nation%></td>\
|
<td><%nation%></td>\
|
||||||
<td><%experience%></td>\
|
<td><%experienceStr%></td>\
|
||||||
<td><%dedication%></td>\
|
<td><%dedicationStr%></td>\
|
||||||
<td><%officerLevel%></td>\
|
<td><%officerLevelStr%></td>\
|
||||||
<td><%total%></td>\
|
<td><%total%></td>\
|
||||||
<td><%leadership%></td>\
|
<td><%leadership%></td>\
|
||||||
<td><%strength%></td>\
|
<td><%strength%></td>\
|
||||||
@@ -420,9 +420,7 @@ $(function ($) {
|
|||||||
|
|
||||||
$('#btn_load_general_list').on('click', async function () {
|
$('#btn_load_general_list').on('click', async function () {
|
||||||
try {
|
try {
|
||||||
const result = await SammoAPI.Global.GeneralList({
|
const result = await SammoAPI.Global.GeneralListWithToken();
|
||||||
with_token: true,
|
|
||||||
});
|
|
||||||
printGeneralList(result);
|
printGeneralList(result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
Generated
+6
-6
@@ -5622,9 +5622,9 @@
|
|||||||
"integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA=="
|
"integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA=="
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.14.8",
|
"version": "1.14.9",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||||
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
|
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -14691,9 +14691,9 @@
|
|||||||
"integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA=="
|
"integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA=="
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
"follow-redirects": {
|
||||||
"version": "1.14.8",
|
"version": "1.14.9",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||||
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA=="
|
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
|
||||||
},
|
},
|
||||||
"fraction.js": {
|
"fraction.js": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user