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); }