From b9926b8e5a24b20fc291689cb52a84999f313c63 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Tue, 31 Oct 2023 21:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=AB=E5=86=99=E7=94=A8=E6=88=B7=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/User.php | 14 ++++++++++++++ app/api/model/User.php | 21 +++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 70457b8..fdd5003 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -107,4 +107,18 @@ class User extends Controller } return $this->renderSuccess('恭喜您,密码设置成功'); } + + /** + * 填写用户身份信息 + * @return Json + * @throws BaseException + */ + public function userAuthentication(): Json + { + $model = new UserModel; + if (!$model->saveAuthenticationData($this->postForm())) { + return $this->renderSuccess($model->getError() ?: '操作失败'); + } + return $this->renderSuccess('恭喜您,身份填写成功'); + } } diff --git a/app/api/model/User.php b/app/api/model/User.php index bc84db0..0ebcbf1 100644 --- a/app/api/model/User.php +++ b/app/api/model/User.php @@ -133,12 +133,29 @@ class User extends UserModel * @return bool * @throws BaseException */ - public function savePassword(array $data): bool + public function savePassword(array $form): bool { // 当前登录的用户信息 $userInfo = UserService::getCurrentLoginUser(true); // 默认数据 - $data['password'] = encryption_hash($data['password']); + $data['password'] = encryption_hash($form['password']); + // 更新用户记录 + return $userInfo->save($data); + } + + /** + * 填写身份信息 + * @param $form + * @return bool + * @throws BaseException + */ + public function saveAuthenticationData($form): bool + { + // 当前登录的用户信息 + $userInfo = UserService::getCurrentLoginUser(true); + // 默认数据 + $data['id_no'] = $form['id_no']; + $data['real_name'] = $form['real_name']; // 更新用户记录 return $userInfo->save($data); }