feat: add note module and route fixes
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\note\controller;
|
||||
|
||||
/**
|
||||
* note 模块基础控制器
|
||||
*/
|
||||
abstract class BaseController extends \app\api\controller\BaseController
|
||||
{
|
||||
/**
|
||||
* 获取当前 note 模块登录用户 ID。
|
||||
*
|
||||
* 说明:
|
||||
* - note 模块复用全局 JWT 中间件
|
||||
* - 但要求 token 载荷中必须带 `guard=note`
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getCurrentNoteUserId(): int
|
||||
{
|
||||
$payload = $this->getLoginPayload();
|
||||
|
||||
if (($payload['guard'] ?? '') !== 'note') {
|
||||
throw new \RuntimeException('note 模块登录态无效', 401);
|
||||
}
|
||||
|
||||
return (int) ($payload['userid'] ?? 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user