diff --git a/doc/NGun.py b/doc/Gun.py similarity index 60% rename from doc/NGun.py rename to doc/Gun.py index 178dbea..1775420 100644 --- a/doc/NGun.py +++ b/doc/Gun.py @@ -2,36 +2,38 @@ import _common -class NGun(object): +class Gun(object): def __init__(self): self.apis = [ { - 'desc': 'getGunInfo', - 'group': 'NGun', - 'url': 'webapp/index.php?c=NGun&a=getGunInfo', + 'desc': '获取枪支信息-getGunInfo', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=getGunInfo', 'params': [ _common.ReqHead(), ], 'response': [ _common.RspHead(), + ['!data', [_common.GunInfo()], '枪支信息列表'] ] }, { - 'desc': 'skillLvUp', - 'group': 'NGun', - 'url': 'webapp/index.php?c=NGun&a=skillLvUp', + 'desc': '升级枪支技能等级skillLvUp', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=skillLvUp', 'params': [ _common.ReqHead(), ], 'response': [ _common.RspHead(), + ['data', _common.GunInfo(), '枪支信息'] ] }, { 'desc': 'getGunAndSkinInfo', - 'group': 'NGun', - 'url': 'webapp/index.php?c=NGun&a=getGunAndSkinInfo', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=getGunAndSkinInfo', 'params': [ _common.ReqHead(), ], @@ -41,8 +43,8 @@ class NGun(object): }, { 'desc': 'equipGunSkin', - 'group': 'NGun', - 'url': 'webapp/index.php?c=NGun&a=equipGunSkin', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=equipGunSkin', 'params': [ _common.ReqHead(), ], @@ -52,8 +54,8 @@ class NGun(object): }, { 'desc': 'buyGunSkin', - 'group': 'NGun', - 'url': 'webapp/index.php?c=NGun&a=buyGunSkin', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=buyGunSkin', 'params': [ _common.ReqHead(), ], diff --git a/doc/_common.py b/doc/_common.py index f3338ca..73f2ac5 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -15,3 +15,12 @@ class RspHead(object): ['errcode', 0, '错误码'], ['errmsg', '', '错误描述'], ] + +class GunInfo(object): + + def __init__(self): + self.fields = [ + ['gun_type_id', 0, '枪支类型'], + ['skill_id', 0, '技能id'], + ['skill_lv', 0, '技能等级'], + ] diff --git a/third_party/phpcommon b/third_party/phpcommon index b93b4f4..c07d074 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit b93b4f400cc743d5624e755530da14f428fdc026 +Subproject commit c07d074acbdc49eab57e0eb1f7ae6afa3f1c9ab9 diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 9eebeae..a839551 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -95,13 +95,6 @@ class BaseAuthedController extends BaseController { )); } - protected function rspData($data) - { - $data['errno'] = 0; - $data['errmsg'] = ''; - echo json_encode($data); - } - protected function isValidSex($sex) { return in_array($sex, array(0, 1, 2)); diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index e873a72..3150ee7 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -34,4 +34,34 @@ class BaseController { return max(0, $this->getNowDaySeconds() + 3600 * 24 - $this->getNowTime()); } + protected function rspErr($errcode, $errmsg) + { + echo json_encode(array( + 'errcode' => $errcode, + 'errmsg' => $errmsg, + )); + } + + protected function rspOk() + { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } + + protected function rspData($data) + { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'data' => $data + )); + } + + protected function rspRawData($rawData) + { + echo json_encode($rawData); + } + } diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 2262f09..b7507ab 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -6,23 +6,30 @@ class GunController extends BaseAuthedController { public function getGunInfo() { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - - // $row = $conn->execQueryOne('SELECT guildcoin_num FROM user WHERE accountid=:accountid;', - // array( - // ':accountid' => $account_id - // )); - $sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) { - // error_log("GunTest3======"); - } - else{ - //error_log("GunTest4======="); - } - $this->sendDataToClient(0,"test02",$row); + $data = array(); + phpcommon\SqlHelper::select + ( + $this->getSelfMysql(), + 'gun_intensify', + array( + 'gun_type_id', + 'skill_id', + 'skill_lv' + ), + array( + 'accountid' => $this->getAccountId() + ), + function ($row) use(&$data) { + array_push($data, array( + 'gun_type_id' => $row['gun_type_id'], + 'skill_id' => $row['skill_id'], + 'skill_lv' => $row['skill_lv'], + )); + } + ); + $this->rspData($data); } + public function skillLvUp() { $code = 100;