添加默认系统管理员账号并限制唯一

This commit is contained in:
2026-07-04 09:53:57 +08:00
parent 323f50bfc0
commit 5a50af66bf
4 changed files with 52 additions and 8 deletions
+7 -8
View File
@@ -32,16 +32,15 @@ open http://localhost:3018
| 后端 API | 3019 |
| PostgreSQL | 5432 |
## 创建首个系统管理员
## 默认系统管理员
系统不内置默认账号。启动后,先注册一个普通用户,再通过 SQL 将其提升为系统管理员
系统启动时会自动创建一个系统管理员账号(仅当不存在时)
```bash
docker compose exec db psql -U stock -d stock -c "
UPDATE users SET role_id = (SELECT id FROM roles WHERE name = 'system_admin')
WHERE username = '你的用户名';
"
```
| 用户名 | 密码 |
|---|---|
| `system_admin` | `system_admin` |
整个系统只能有一个系统管理员账号,无法通过管理后台再创建或提升其他系统管理员。
## 角色说明