game2005api/webapp/controller/RankingController.class.php
aozhiwei ac9b9f1411 1
2021-12-13 19:37:12 +08:00

76 lines
2.4 KiB
PHP

<?php
require_once('models/User.php');
use phpcommon\SqlHelper;
use models\User;
class RankingController extends BaseAuthedController {
public function rankingList()
{
$userInfo = $this->_getOrmUserInfo();
$type = getReqVal('type', 0);
$userList = array();
{
SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_user',
array(
),
function ($row) use(&$userList) {
array_push($userList, User::info($row));
}
);
}
$rankingList = array();
$ranked = 1;
foreach ($userList as $user) {
array_push($rankingList, array(
'ranked' => $ranked++,
'account_id' => $user['account_id'],
'name' => $user['name'],
'name' => $user['name'],
'sex' => $user['sex'],
'head_id' => $user['hero_id'],
'head_frame' => $user['head_frame'],
'level' => $user['level'],
'exp' => $user['exp'],
'rank' => $user['rank'],
'score' => $user['score'],
'gold' => $user['gold'],
'diamond' => $user['diamond'],
'hero_id' => $user['hero_id'],
'first_fight' => $user['first_fight'],
));
}
$rankingData = array(
'type' => $type,
'ranking_list' => $rankingList,
'my_ranked' => array(
'ranked' => -1,
'account_id' => $this->_getAccountId(),
'name' => $userInfo['name'],
'name' => $userInfo['name'],
'sex' => $userInfo['sex'],
'head_id' => $userInfo['hero_id'],
'head_frame' => $userInfo['head_frame'],
'level' => $userInfo['level'],
'exp' => $userInfo['exp'],
'rank' => $userInfo['rank'],
'score' => $userInfo['score'],
'gold' => $userInfo['gold'],
'diamond' => $userInfo['diamond'],
'hero_id' => $userInfo['hero_id'],
'first_fight' => $userInfo['first_fight'],
)
);
$this->_rspData(array(
'ranking_list' =>$rankingData
));
}
}