From 11d3b7cdf411f62f39b7a5ba8b6fbc9b59142675 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Nov 2021 13:55:16 +0800 Subject: [PATCH] info@User ok --- doc/User.py | 27 ++++++++++++++++++++++ doc/_common.py | 1 + webapp/controller/UserController.class.php | 26 +++++++++++++++++++++ webapp/models/User.php | 18 +++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/doc/User.py b/doc/User.py index 7f90949a..cdbf8af2 100644 --- a/doc/User.py +++ b/doc/User.py @@ -19,6 +19,33 @@ class User(object): ['info',_common.UserInfo(), '用户信息'] ] }, + { + 'name': 'update', + 'desc': '更新用户信息', + 'group': 'User', + 'url': 'webapp/index.php?c=User&a=update', + 'params': [ + _common.ReqHead(), + ['hero_id', 0, '更新上阵英雄id(可选参数,不传就不更新)'] + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'name': 'info', + 'desc': '获取用户信息', + 'group': 'User', + 'url': 'webapp/index.php?c=User&a=info', + 'params': [ + _common.ReqHead(), + ['target_id', '', '用户account_id(如果要获取自己的就传自己的account_id)'] + ], + 'response': [ + _common.RspHead(), + ['info',_common.UserInfo(), '用户信息'] + ] + }, { 'name': 'clientBattleReport', 'desc': '客户端战报', diff --git a/doc/_common.py b/doc/_common.py index f00c82f8..f0217524 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -38,6 +38,7 @@ class UserInfo(object): def __init__(self): self.fields = [ + ['account_id', '', '账号id'], ['name', '', '用户名字'], ['head_id', 0, '头像id'], ['head_frame', 0, '头像框id'], diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 5343d663..32280d9b 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -91,6 +91,32 @@ class UserController extends BaseAuthedController { } } + public function update() + { + $validFields = array( + + ); + } + + public function info() + { + $targetId = getReqVal('target_id', ''); + $userDb = SqlHelper::ormSelectOne + ($this->_getMysql($targetId), + 't_user', + array( + 'account_id' => $targetId + ) + ); + if (!$userDb) { + $this->_rspErr(1, '账号不存在'); + return; + } + $this->_rspData(array( + 'info' => User::info($userDb) + )); + } + public function clientBattleReport() { $this->_updateUserInfo(array( diff --git a/webapp/models/User.php b/webapp/models/User.php index 079bab30..0cb75936 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -7,6 +7,24 @@ class User extends BaseModel { public static function show($row) { return array( + 'account_id' => $row['account_id'], + 'name' => $row['name'], + 'sex' => $row['sex'], + 'head_id' => $row['hero_id'], + 'head_frame' => $row['head_frame'], + 'level' => $row['level'], + 'exp' => $row['exp'], + 'gold' => $row['gold'], + 'diamond' => $row['diamond'], + 'hero_id' => $row['hero_id'], + 'first_fight' => $row['first_fight'], + ); + } + + public static function info($row) + { + return array( + 'account_id' => $row['account_id'], 'name' => $row['name'], 'sex' => $row['sex'], 'head_id' => $row['hero_id'],