From f40ebe1918532628b62d3f9ce5b13418970eadd5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 26 Dec 2023 17:25:48 +0800 Subject: [PATCH] 1 --- webapp/controller/MatchController.class.php | 41 ++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/webapp/controller/MatchController.class.php b/webapp/controller/MatchController.class.php index 0891c8a9..f2d790a1 100644 --- a/webapp/controller/MatchController.class.php +++ b/webapp/controller/MatchController.class.php @@ -43,21 +43,7 @@ class MatchController extends BaseAuthedController { $this->refreshKeyExpire($r, TEAMID_KEY . $matchOkDb['target_team'], 1000*600); $this->fillMatchInfo($r, $teamUuid, $matchInfo, $matchOkDb); } else { - $currMatchDb = $this->readCurrMatchTeam($r); - if (empty($currMatchDb)) { - $currMatchDb = array( - 'current_team' => $teamUuid, - 'match_time' => $this->_getNowTime() - ); - $r->set(MATCH_CURRENT_TEAM_KEY, json_encode($currMatchDb)); - $this->refreshKeyExpire($r, MATCH_CURRENT_TEAM_KEY, 1000*600); - } else { - if ($currMatchDb['current_team'] != $teamUuid) { - $this->matchOk($r, $teamUuid, $currMatchDb); - $this->fillMatchInfo($r, $teamUuid, $matchInfo, $this->readMatchOk($r, $teamUuid)); - } else { - } - } + $this->execMatch($r, $teamUuid, $teamDb, $matchInfo); } $this->_rspData($matchInfo); } @@ -90,8 +76,10 @@ class MatchController extends BaseAuthedController { /* { - "current_team": "dafsdf" - "match_time": 231434 + "": { + "current_team": "dafsdf" + "match_time": 231434 + } } */ private function readCurrMatchTeam($r) @@ -126,6 +114,25 @@ class MatchController extends BaseAuthedController { $r->pexpire($key, $time); } + private function execMatch($r, $teamUuid, $teamDb, &$matchInfo) + { + $currMatchDb = $this->readCurrMatchTeam($r); + if (empty($currMatchDb)) { + $currMatchDb = array( + 'current_team' => $teamUuid, + 'match_time' => $this->_getNowTime() + ); + $r->set(MATCH_CURRENT_TEAM_KEY, json_encode($currMatchDb)); + $this->refreshKeyExpire($r, MATCH_CURRENT_TEAM_KEY, 1000*600); + } else { + if ($currMatchDb['current_team'] != $teamUuid) { + $this->matchOk($r, $teamUuid, $currMatchDb); + $this->fillMatchInfo($r, $teamUuid, $matchInfo, $this->readMatchOk($r, $teamUuid)); + } else { + } + } + } + private function matchOk($r, $teamUuid, $currMatchDb) { {