modified 统一更新用户信息

This commit is contained in:
zhaoxiang 2019-06-19 15:46:38 +08:00
parent a71f6e723e
commit 05ee080d1a

View File

@ -7,6 +7,8 @@
namespace app\admin\controller;
use app\model\AdminUser;
use app\model\AdminUserData;
use app\util\ReturnCode;
use think\Controller;
@ -33,6 +35,27 @@ class Base extends Controller {
return $return;
}
/**
* 更新用户信息
* @param $data
* @param bool $isDetail
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
public function updateUserInfo($data, $isDetail = false) {
$apiAuth = $this->request->header('apiAuth');
if ($isDetail) {
AdminUserData::update($data, ['uid' => $this->userInfo['id']]);
$this->userInfo['userData'] = AdminUserData::get(['uid' => $this->userInfo['id']]);
} else {
AdminUser::update($data, ['id' => $this->userInfo['id']]);
$detail = $this->userInfo['userData'];
$this->userInfo = AdminUser::get(['id' => $this->userInfo['id']]);
$this->userInfo['userData'] = $detail;
}
cache('Login:' . $apiAuth, json_encode($this->userInfo), config('apiadmin.ONLINE_TIME'));
}
public function buildFailed($code, $msg, $data = []) {
$return = [
'code' => $code,