feat: 新增 GET /api/v1/profile 用户信息查询接口,支持前端凭据查询当前用户
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,33 @@ Auth: JWT(可接受已过期的 token,或在 body 中提供 refresh_token)
|
||||
|
||||
---
|
||||
|
||||
### GET /profile — 查询当前用户
|
||||
|
||||
Auth: JWT。根据 token 返回当前登录用户的信息。
|
||||
|
||||
```json
|
||||
// 响应 200
|
||||
{
|
||||
"user_id": "admin",
|
||||
"username": "admin",
|
||||
"nickname": "叶酱",
|
||||
"is_admin": true,
|
||||
"created_at": "2024-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| `user_id` | string | 用户 ID(admin 为 `"admin"`,普通用户为 `"user_<username>"`) |
|
||||
| `username` | string | 用户名 |
|
||||
| `nickname` | string | 显示昵称 |
|
||||
| `is_admin` | bool | 是否管理员 |
|
||||
| `created_at` | string | 注册时间 (RFC3339),数据库不可用时为 null |
|
||||
|
||||
错误: 401 `未提供认证令牌`, 404 `用户不存在`
|
||||
|
||||
---
|
||||
|
||||
## 2. WebSocket 实时通信
|
||||
|
||||
### GET /ws/chat — 建立连接
|
||||
|
||||
Reference in New Issue
Block a user