From c1b2511f053dc1f0c4050299ad4529cd7d40ccab Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Mon, 7 Oct 2024 20:11:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/common.php | 26 +++++++++++++------------- app/api/controller/Passport.php | 8 +++----- app/api/service/UserService.php | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/api/common.php b/app/api/common.php index 8ebffca..873c690 100644 --- a/app/api/common.php +++ b/app/api/common.php @@ -1,14 +1,14 @@ request->isPost()) { return $this->renderError('不支持GET请求'); } - $data = $this->postData(); $model = new UserService; - // - $data = $this->postData(); - if (($userInfo = $model->register($data['uname'],$data['upass'])) === false) { - return $this->renderSuccess("登录成功"); + if (($userInfo = $model->register($this->postData())) === false) { + return $this->renderError($model->getError() ?: '注册失败'); } + return $this->renderSuccess("注册成功"); } } \ No newline at end of file diff --git a/app/api/service/UserService.php b/app/api/service/UserService.php index e41e670..21d5dd5 100644 --- a/app/api/service/UserService.php +++ b/app/api/service/UserService.php @@ -1,4 +1,5 @@ save($arr); - return true; + // 保存 + $model = new User; + $uid = $model->save($arr); + return isset($uid)?true:false; } } \ No newline at end of file