1
This commit is contained in:
parent
11d3b7cdf4
commit
b933b7f747
@ -30,6 +30,7 @@ class User(object):
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
['info',_common.UserInfo(), '更新后的用户信息'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ class User(object):
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['info',_common.UserInfo(), '用户信息']
|
['info',_common.UserInfo(), '用户信息'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -94,8 +94,44 @@ class UserController extends BaseAuthedController {
|
|||||||
public function update()
|
public function update()
|
||||||
{
|
{
|
||||||
$validFields = array(
|
$validFields = array(
|
||||||
|
'hero_id' => array(
|
||||||
|
'field_name' => 'hero_id',
|
||||||
|
'val_func' => function ($val) {
|
||||||
|
return $val;
|
||||||
|
},
|
||||||
|
'valid_func' => function ($val, &$errCode, &$errMsg) {
|
||||||
|
if (Hero::find($val)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$errCode = 1;
|
||||||
|
$errMsg = '英雄不存在';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
$fieldsKv = array();
|
||||||
|
$errCod = 0;
|
||||||
|
$errMsg = '';
|
||||||
|
foreach ($validFields as $key => $field) {
|
||||||
|
$reqVal = getReqVal($key, '');
|
||||||
|
if (!empty($reqVal)) {
|
||||||
|
if (isset($field['valid_func'])) {
|
||||||
|
if (!$field['valid_func']($reqVal, $errCode, $errMsg)) {
|
||||||
|
$this->_rspErr($errCode, $errMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$fieldsKv[$field['field_name']] = $field['val_func']($reqVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($fieldsKv) > 0) {
|
||||||
|
$this->_updateUserInfo($fieldsKv);
|
||||||
|
}
|
||||||
|
$this->_rspData(array(
|
||||||
|
'info' => User::info($this->_getUserInfo())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function info()
|
public function info()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user