完善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
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(),
],

View File

@ -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, '技能等级'],
]

@ -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)
{
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());
}
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()
{
$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;