完善Gun接口

This commit is contained in:
aozhiwei 2021-11-17 19:21:53 +08:00
parent 23197efdd2
commit 2337dfdf0e
6 changed files with 78 additions and 37 deletions

View File

@ -2,36 +2,38 @@
import _common import _common
class NGun(object): class Gun(object):
def __init__(self): def __init__(self):
self.apis = [ self.apis = [
{ {
'desc': 'getGunInfo', 'desc': '获取枪支信息-getGunInfo',
'group': 'NGun', 'group': 'Gun',
'url': 'webapp/index.php?c=NGun&a=getGunInfo', 'url': 'webapp/index.php?c=Gun&a=getGunInfo',
'params': [ 'params': [
_common.ReqHead(), _common.ReqHead(),
], ],
'response': [ 'response': [
_common.RspHead(), _common.RspHead(),
['!data', [_common.GunInfo()], '枪支信息列表']
] ]
}, },
{ {
'desc': 'skillLvUp', 'desc': '升级枪支技能等级skillLvUp',
'group': 'NGun', 'group': 'Gun',
'url': 'webapp/index.php?c=NGun&a=skillLvUp', 'url': 'webapp/index.php?c=Gun&a=skillLvUp',
'params': [ 'params': [
_common.ReqHead(), _common.ReqHead(),
], ],
'response': [ 'response': [
_common.RspHead(), _common.RspHead(),
['data', _common.GunInfo(), '枪支信息']
] ]
}, },
{ {
'desc': 'getGunAndSkinInfo', 'desc': 'getGunAndSkinInfo',
'group': 'NGun', 'group': 'Gun',
'url': 'webapp/index.php?c=NGun&a=getGunAndSkinInfo', 'url': 'webapp/index.php?c=Gun&a=getGunAndSkinInfo',
'params': [ 'params': [
_common.ReqHead(), _common.ReqHead(),
], ],
@ -41,8 +43,8 @@ class NGun(object):
}, },
{ {
'desc': 'equipGunSkin', 'desc': 'equipGunSkin',
'group': 'NGun', 'group': 'Gun',
'url': 'webapp/index.php?c=NGun&a=equipGunSkin', 'url': 'webapp/index.php?c=Gun&a=equipGunSkin',
'params': [ 'params': [
_common.ReqHead(), _common.ReqHead(),
], ],
@ -52,8 +54,8 @@ class NGun(object):
}, },
{ {
'desc': 'buyGunSkin', 'desc': 'buyGunSkin',
'group': 'NGun', 'group': 'Gun',
'url': 'webapp/index.php?c=NGun&a=buyGunSkin', 'url': 'webapp/index.php?c=Gun&a=buyGunSkin',
'params': [ 'params': [
_common.ReqHead(), _common.ReqHead(),
], ],

View File

@ -15,3 +15,12 @@ class RspHead(object):
['errcode', 0, '错误码'], ['errcode', 0, '错误码'],
['errmsg', '', '错误描述'], ['errmsg', '', '错误描述'],
] ]
class GunInfo(object):
def __init__(self):
self.fields = [
['gun_type_id', 0, '枪支类型'],
['skill_id', 0, '技能id'],
['skill_lv', 0, '技能等级'],
]

@ -1 +1 @@
Subproject commit b93b4f400cc743d5624e755530da14f428fdc026 Subproject commit c07d074acbdc49eab57e0eb1f7ae6afa3f1c9ab9

View File

@ -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) protected function isValidSex($sex)
{ {
return in_array($sex, array(0, 1, 2)); return in_array($sex, array(0, 1, 2));

View File

@ -34,4 +34,34 @@ class BaseController {
return max(0, $this->getNowDaySeconds() + 3600 * 24 - $this->getNowTime()); 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);
}
} }

View File

@ -6,23 +6,30 @@ class GunController extends BaseAuthedController {
public function getGunInfo() public function getGunInfo()
{ {
$account_id = $_REQUEST['account_id']; $data = array();
$conn = $this->getMysql($account_id); phpcommon\SqlHelper::select
(
// $row = $conn->execQueryOne('SELECT guildcoin_num FROM user WHERE accountid=:accountid;', $this->getSelfMysql(),
// array( 'gun_intensify',
// ':accountid' => $account_id array(
// )); 'gun_type_id',
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; "; 'skill_id',
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); 'skill_lv'
if($row) { ),
// error_log("GunTest3======"); array(
} 'accountid' => $this->getAccountId()
else{ ),
//error_log("GunTest4======="); function ($row) use(&$data) {
} array_push($data, array(
$this->sendDataToClient(0,"test02",$row); 'gun_type_id' => $row['gun_type_id'],
'skill_id' => $row['skill_id'],
'skill_lv' => $row['skill_lv'],
));
}
);
$this->rspData($data);
} }
public function skillLvUp() public function skillLvUp()
{ {
$code = 100; $code = 100;