From b2386e0fd7a7b36a96266f922cd7fac451e8e0e6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 24 Jun 2020 18:30:46 +0800 Subject: [PATCH] 1 --- webapp/controller/FriendController.class.php | 103 +++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 webapp/controller/FriendController.class.php diff --git a/webapp/controller/FriendController.class.php b/webapp/controller/FriendController.class.php new file mode 100644 index 0000000..3284837 --- /dev/null +++ b/webapp/controller/FriendController.class.php @@ -0,0 +1,103 @@ + $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => 'gamedb2004_' . $mysql_conf['instance_id'] + )); + return $conn; + } + protected function getSeasonPoint($seaPoint_id) + { + $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); + $seaPoint_meta = getSeasonPointConfig($seaPoint_meta_table, $seaPoint_id); + $seaPoint = array( + 'id' => $seaPoint_meta['id'], + 'min' => $seaPoint_meta['min_point'], + 'max' => $seaPoint_meta['max_point'], + 'des' => $seaPoint_meta['des'], + ); + return $seaPoint; + } + + public function selectUserInfo() + { + $account_id = $_REQUEST['account_id']; + $conn = $this->getMysql($account_id); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); + return; + } + $row = $conn->execQueryOne('SELECT accountid, user_name, avatar_url, game_times, win_times, kill_his, kills, harm_his, harm, integral, modify_time, alive_time, add_HP FROM user WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); + return; + } + + $rank = 1; + $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); + for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { + $seaPoint = $this->getSeasonPoint($ii); + if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] + || $seaPoint['max'] == -1) { + $rank = $ii; + break; + } + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'accountid' => $row['accountid'], + 'user_name' => $row['user_name'], + 'avatar_url' => $row['avatar_url'], + 'game_times' => $row['game_times'], + 'win_times' => $row['win_times'], + 'kill_his' => $row['kill_his'], + 'kills' => $row['kills'], + 'harm_his' => $row['harm_his'], + 'harm' => $row['harm'], + 'level' => $rank, + 'modify_time' => $row['modify_time'], + 'alive_time' => $row['alive_time'], + 'add_HP' => $row['add_HP'], + )); + } + + public function selectUser() + { + $account_id = $_REQUEST['account_id']; + $conn = $this->getMysql($account_id); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); + return; + } + $row = $conn->execQueryOne('SELECT accountid FROM user WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } +} +?>