fix: 修复参数接收强制转换

This commit is contained in:
Ying
2023-06-25 16:56:18 +08:00
parent b4b73ac2aa
commit 34dd0a2086
3 changed files with 22 additions and 18 deletions

View File

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

View File

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

View File

@@ -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,8 +211,6 @@ class Third extends HomeController
}
$result = UserTokenService::isLogin();
if (!empty($result)) {
if (empty($result['email']) || empty($result['pwd'])) {
return $this->error('解除绑定需要设置邮箱和密码!');
}
@@ -215,7 +220,6 @@ class Third extends HomeController
if (UserThird::where($where)->delete()) {
return $this->success('解除绑定成功!');
}
}
return $this->error();
}