门户端接口【内部使用】3、个人中心
3.1 获取当前用户信息
GET
/api/user/self3.1 获取当前用户信息
获取当前用户信息
接口地址: GET /api/user/self
权限要求: 🔐 需要登录(User权限)
描述: 获取当前登录用户的详细信息
请求头:
token: {access_token}请求头说明:
token(必填): JWT 访问令牌
兼容性说明:
- 为向后兼容,也支持
Authorization: Bearer {access_token}请求头
请求示例:
curl -X GET "https://your-domain.com/api/user/self" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."请求参数: 无
返回数据:
{ "success": true, "message": "", "data": { "id": 1, "username": "user1", "display_name": "User One", "role": 1, "status": 1, "email": "user@example.com", "github_id": "", "discord_id": "", "oidc_id": "", "wechat_id": "", "telegram_id": "", "group": "default", "quota": 100000, "used_quota": 50000, "request_count": 100, "aff_code": "abc123", "aff_count": 5, "aff_quota": 50000, "aff_charged_count": 3, "inviter_id": 0, "linux_do_id": "", "setting": "{}", "stripe_customer": "", "sidebar_modules": {}, "permissions": {}, "avatar_url": "", "phone": "", "profit_quota": 0, "aff_history_count": 5, "aff_history": 100000, "has_password": true, "creation_num": 12, "quota_usd": 0.2, "used_quota_usd": 0.1, "aff_quota_usd": 0.1, "aff_history_usd": 0.2, "profit_quota_usd": 0.0 }}返回字段说明:
| 字段 | 类型 | 说明 |
|---|---|---|
| id | int | 用户ID |
| username | string | 用户名 |
| display_name | string | 显示名称 |
| role | int | 用户角色(1=普通用户,10=管理员,100=超级管理员) |
| status | int | 用户状态(1=启用,2=禁用) |
| string | 邮箱 | |
| github_id | string | GitHub ID |
| discord_id | string | Discord ID |
| oidc_id | string | OIDC ID |
| wechat_id | string | 微信ID |
| telegram_id | string | Telegram ID |
| group | string | 用户分组 |
| quota | int | 剩余配额 |
| used_quota | int | 已使用配额 |
| request_count | int | 请求次数 |
| aff_code | string | 推荐码 |
| aff_count | int | 推荐人数(邀请用户已注册数量) |
| aff_quota | int | 推荐奖励配额(剩余可转出的额度) |
| aff_history | int | 历史推荐总数(累计获得的邀请奖励配额总额) |
| aff_history_count | int | 总共发起邀请连接次数 |
| aff_charged_count | int | 已充值邀请人数 |
| inviter_id | int | 邀请人ID |
| linux_do_id | string | LinuxDo ID |
| setting | string | 用户设置JSON |
| stripe_customer | string | Stripe客户ID |
| sidebar_modules | object | 侧边栏模块配置 |
| permissions | object | 用户权限信息 |
| avatar_url | string | 头像URL |
| phone | string | 手机号 |
| profit_quota | int | 累计收益配额 |
| has_password | boolean | 是否设置密码(true=已设置,false=未设置) |
| creation_num | int | 用户作品数量,统计 creation_info 表中当前用户 deleted=0 的记录总数 |
| quota_usd | float | 剩余配额(USD),通过 quota / QuotaPerUnit 换算 |
| used_quota_usd | float | 已使用配额(USD),通过 used_quota / QuotaPerUnit 换算 |
| aff_quota_usd | float | 推荐奖励配额(USD),通过 aff_quota / QuotaPerUnit 换算 |
| aff_history_usd | float | 历史推荐总数(USD),通过 aff_history / QuotaPerUnit 换算 |
| profit_quota_usd | float | 累计收益配额(USD),通过 profit_quota / QuotaPerUnit 换算 |