feat: add note module and route fixes

This commit is contained in:
nepiedg
2026-04-17 07:48:44 +00:00
parent 866ddb046b
commit 84e1c0daac
25 changed files with 2196 additions and 38 deletions
+30
View File
@@ -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);
}
}