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
@@ -42,6 +42,36 @@ abstract class BaseController
protected function initialize()
{}
/**
* 获取当前登录用户载荷。
*
* 说明:
* - 登录态由路由中间件 `\app\api\middleware\Auth` 统一校验
* - 控制器只负责读取中间件已经注入的用户信息
*
* @return array
*/
protected function getLoginPayload(): array
{
$payload = $this->request->middleware('payload', []);
if (empty($payload['userid'])) {
throw new \RuntimeException('未登录', 401);
}
return $payload;
}
/**
* 获取当前登录用户 ID。
*
* @return int
*/
protected function getLoginUserId(): int
{
return (int) $this->getLoginPayload()['userid'];
}
/**
* 成功响应
* @param mixed $data 返回数据