diff --git a/app/admin/controller/system/Dictionary.php b/app/admin/controller/system/Dictionary.php index ef6d742..8e0f8f3 100644 --- a/app/admin/controller/system/Dictionary.php +++ b/app/admin/controller/system/Dictionary.php @@ -43,8 +43,8 @@ class Dictionary extends AdminController { $post = input(); $pid = input('pid'); - $limit = input('limit/d') ?? 10; - $page = input('page/d') ?? 1; + $limit = input('limit') ?? 10; + $page = input('page') ?? 1; if ($pid == null) { $pid = (string)$this->model->minId(); } diff --git a/app/api/controller/User.php b/app/api/controller/User.php index ee63ad1..30badfd 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -163,8 +163,8 @@ class User extends ApiController */ public function message(Request $request): Response { - $page = input('page/d', 1); - $limit = input('limit/d', 1); + $page = input('page', 1); + $limit = input('limit', 1); $status = input('status', 'all'); $where[] = ['user_id', '=', $request->userId]; if ($status !== 'all') { @@ -185,7 +185,7 @@ class User extends ApiController */ public function viewMessage(Request $request): Response { - $id = input('id/d', 0); + $id = input('id', 0); $result = UserService::viewMessage($id, $request->userId); return $this->success('查询成功', "/", $result); } diff --git a/app/index/controller/Third.php b/app/index/controller/Third.php index ab32380..191a979 100644 --- a/app/index/controller/Third.php +++ b/app/index/controller/Third.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\index\controller; +use app\common\exception\OperateException; use app\common\library\ResultCode; use app\common\service\user\UserService; use app\common\service\user\UserTokenService; @@ -92,8 +93,9 @@ class Third extends HomeController * @return Response * @throws DataNotFoundException * @throws DbException - * @throws ModelNotFoundException * @throws InvalidArgumentException + * @throws ModelNotFoundException + * @throws OperateException */ public function callback() { @@ -102,24 +104,29 @@ class Third extends HomeController } catch (\Exception $e) { return $this->error($e->getMessage()); } + $user = $this->oauth->getUserInfo(); if (!empty($user) && !UserTokenService::isLogin()) { return $this->register($user, $this->type); } else if (UserTokenService::isLogin()) { // 绑定用户 return $this->doBind($user, $this->type); } + + return $this->error('登录失败'); } /** * 用户注册操作 * @param array $info - * @param string|null $type + * @param string $type * @return Response * @throws DataNotFoundException * @throws DbException + * @throws InvalidArgumentException * @throws ModelNotFoundException + * @throws OperateException */ - protected function register(array $info = [], string $type = null) + protected function register(array $info, string $type): Response { $openid = $info['openid'] ?? $info['id']; $nickname = $info['userData']['name'] ?? $info['userData']['nickname']; @@ -204,17 +211,14 @@ class Third extends HomeController } $result = UserTokenService::isLogin(); - if (!empty($result)) { + if (empty($result['email']) || empty($result['pwd'])) { + return $this->error('解除绑定需要设置邮箱和密码!'); + } - if (empty($result['email']) || empty($result['pwd'])) { - return $this->error('解除绑定需要设置邮箱和密码!'); - } - - $where['type'] = $this->type; - $where['user_id'] = request()->userId; - if (UserThird::where($where)->delete()) { - return $this->success('解除绑定成功!'); - } + $where['type'] = $this->type; + $where['user_id'] = request()->userId; + if (UserThird::where($where)->delete()) { + return $this->success('解除绑定成功!'); } return $this->error();