go-platform/docs/QUICK_START.md
2026-04-09 16:26:38 +08:00

123 lines
2.4 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.

# 🚀 存储配置功能 - 5分钟快速开始
## 第一步安装依赖1分钟
```bash
cd go
go mod download
go mod tidy
```
## 第二步数据库迁移1分钟
```bash
mysql -u root -p your_database < go/migrations/add_storage_config_table.sql
```
验证:
```bash
mysql -u root -p your_database -e "DESC yz_system_storage_config;"
```
## 第三步启动服务1分钟
```bash
cd go
bee run
# 或
go run main.go
```
## 第四步配置存储2分钟
### 方式1使用本地存储无需配置
1. 访问http://localhost:8080/#/system/platformsettings
2. 点击"存储配置"标签
3. 选择"本地存储"
4. 点击"保存设置"
✅ 完成!文件将保存到 `uploads/` 目录
### 方式2使用七牛云存储
1. 访问http://localhost:8080/#/system/platformsettings
2. 点击"存储配置"标签
3. 选择"七牛云存储"
4. 填写配置:
```
AccessKey: 你的AccessKey
SecretKey: 你的SecretKey
Bucket: 你的Bucket名称
CDN域名: https://你的CDN域名
存储区域: z0华东
```
5. 点击"保存设置"
✅ 完成!文件将上传到七牛云
## 测试上传
### 使用Postman测试
```
POST http://localhost:8080/platform/uploadfile
Headers:
Authorization: Bearer your_token
Body:
form-data
file: 选择文件
```
### 使用curl测试
```bash
curl -X POST \
-H "Authorization: Bearer your_token" \
-F "file=@test.jpg" \
http://localhost:8080/platform/uploadfile
```
## 常见问题
### Q1: 依赖安装失败?
```bash
export GOPROXY=https://goproxy.cn,direct
go mod download
```
### Q2: 数据库连接失败?
检查 `go/conf/app.conf` 中的数据库配置:
```ini
mysqluser = root
mysqlpass = your_password
mysqlurls = 127.0.0.1:3306
mysqldb = your_database
```
### Q3: 七牛云上传失败?
1. 检查密钥是否正确
2. 检查Bucket是否存在
3. 检查存储区域是否匹配
4. 测试网络连接:`curl -I https://你的CDN域名`
## 下一步
- 📖 阅读完整文档:`README_STORAGE.md`
- 🔧 查看部署清单:`DEPLOYMENT_CHECKLIST.md`
- 📚 查看使用指南:`docs/storage-config-guide.md`
- ✅ 查看实现报告:`IMPLEMENTATION_COMPLETE.md`
## 获取帮助
- 查看日志:`tail -f logs/server.log`
- 查看错误:`grep ERROR logs/server.log`
- 七牛云文档https://developer.qiniu.com/
---
**🎉 恭喜!你已经完成了存储配置功能的快速开始!**