oauth_nest_demo/HOW_TO_GENERATE.md

83 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 如何生成卡密 - 快速指南
## 🎯 三种生成方式
### 方式一:使用自动化脚本(最简单)⭐
```bash
bash generate-licenses.sh
```
脚本会自动引导你完成:
1. 注册/登录管理员账号
2. 选择卡密类型
3. 输入生成数量
4. 自动生成并显示卡密
5. 可选保存到文件
### 方式二:使用 Swagger UI可视化
1. 启动项目后访问http://localhost:3030/api
2. 注册管理员账号 `POST /user/register`
```json
{
"username": "admin",
"password": "admin123",
"email": "admin@example.com"
}
```
3. 点击右上角 "Authorize",输入 Token
4. 调用 `POST /license/generate` 生成卡密
```json
{
"type": "monthly",
"validDays": 30,
"count": 10
}
```
### 方式三:使用 curl 命令
```bash
# 1. 注册管理员
curl -X POST http://localhost:3030/user/register \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123","email":"admin@example.com"}'
# 2. 使用返回的 token 生成卡密
curl -X POST http://localhost:3030/license/generate \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"monthly","validDays":30,"count":10}'
```
## 📋 管理员权限规则
系统自动识别以下用户为管理员:
- 用户名为 `admin`
- 邮箱包含 `admin`
- 用户名以 `admin_` 开头
## 📚 详细文档
- [GENERATE_LICENSE_GUIDE.md](GENERATE_LICENSE_GUIDE.md) - 完整生成指南
- [LICENSE_SYSTEM.md](LICENSE_SYSTEM.md) - 卡密系统说明
- [QUICKSTART.md](QUICKSTART.md) - 快速开始
## 🚀 快速开始
```bash
# 1. 启动项目
npm run start:dev
# 2. 运行生成脚本
bash generate-licenses.sh
# 3. 按照提示操作即可
```
就这么简单!🎉