| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #!/bin/bash
- # 前端API批量测试脚本
- # 用法: bash test_apis.sh
- BASE_URL="http://localhost:3000/api"
- echo "========== 测试开始 =========="
- test_api() {
- local name="$1"
- local method="$2"
- local endpoint="$3"
- local data="$4"
- echo -e "\n$name"
- if [ -n "$data" ]; then
- curl -s -w "\nHTTP_CODE:%{http_code}\n" -X $method "${BASE_URL}${endpoint}" -H "Content-Type: application/json" -d "$data"
- else
- curl -s -w "\nHTTP_CODE:%{http_code}\n" -X $method "${BASE_URL}${endpoint}"
- fi
- }
- # 认证模块
- test_api "1. 发送验证码" POST "/auth/send-code" '{"phone":"13800138000"}'
- test_api "2. 登录" POST "/auth/login" '{"phone":"13800138000","code":"123456"}'
- test_api "3. 获取用户信息" GET "/auth/user-info"
- # 会员模块
- test_api "4. 获取会员状态" GET "/member/status"
- test_api "5. 获取订阅余额" GET "/subscription/balance"
- # TTS模块
- test_api "6. 获取音色列表" GET "/tts/voices"
- test_api "7. 生成音频" POST "/tts/generate" '{"text":"测试","voiceId":"cherry","voiceParams":{}}'
- # 播放模块 - 测试有效章节ID
- test_api "8. 修改音频公开状态" PUT "/player/audio/712/public" '{"isPublic":true}'
- # 专辑模块
- test_api "9. 获取专辑列表" GET "/book-generator/albums"
- test_api "10. 获取专辑章节" GET "/book-generator/albums/1/chapters"
- test_api "11. 重命名专辑" PUT "/book-generator/album/1/rename" '{"title":"新名称"}'
- test_api "12. 重命名章节(需有效ID)" PUT "/book-generator/album/1/chapters/712/rename" '{"title":"新章节名"}'
- test_api "13. 移动章节(需有效ID)" PUT "/book-generator/album/1/chapters/712/move" '{"newNumber":2}'
- # 书籍生成模块
- test_api "14. 获取书籍列表" GET "/book-generator/langgraph/books"
- test_api "15. 创建书籍" POST "/book-generator/langgraph/books" '{"title":"测试书籍","description":"测试描述"}'
- test_api "16. 获取书籍详情" GET "/book-generator/langgraph/books/1"
- test_api "17. 生成大纲" POST "/book-generator/langgraph/books/1/outline"
- test_api "18. 生成单章" POST "/book-generator/langgraph/books/1/chapters" '{"chapterNumber":1}'
- test_api "19. 生成前言" POST "/book-generator/langgraph/books/1/foreword"
- test_api "20. 生成后记" POST "/book-generator/langgraph/books/1/afterword"
- test_api "21. 获取完整内容" GET "/book-generator/langgraph/books/1/full-content"
- test_api "22. 获取进度" GET "/book-generator/langgraph/books/1/progress"
- test_api "23. 一键生成整本" POST "/book-generator/langgraph/books/1/generate"
- test_api "24. 生成音频" POST "/book-generator/langgraph/books/1/audio" '{"voiceId":"cherry"}'
- test_api "25. 合并音频" POST "/book-generator/langgraph/books/1/merge-audio"
- test_api "26. 切换发布状态" PUT "/book-generator/langgraph/books/1/publish"
- test_api "27. 获取工作流状态" GET "/book-generator/langgraph/workflow/1"
- # 视频模块
- test_api "28. 获取视频项目列表" GET "/video/projects"
- test_api "29. 创建视频项目" POST "/video/projects" '{"title":"测试视频"}'
- test_api "30. 获取视频项目详情" GET "/video/projects/1"
- test_api "31. 更新视频项目" PUT "/video/projects/1" '{"title":"更新标题"}'
- test_api "32. 删除视频项目" DELETE "/video/projects/1"
- test_api "33. 开始生成视频" POST "/video/projects/1/generate"
- test_api "34. 获取生成进度" GET "/video/projects/1/status"
- test_api "35. 获取素材列表" GET "/video/materials"
- test_api "36. 上传素材" POST "/video/materials/upload" '{"type":"image","name":"test","url":"http://example.com/image.jpg"}'
- test_api "37. 从书籍生成视频" POST "/video/books/1/generate"
- # 发布模块
- test_api "38. 获取平台账号" GET "/publish/accounts"
- test_api "39. 绑定平台账号" POST "/publish/accounts" '{"platform":"douyin","cookies":"test"}'
- test_api "40. 验证账号" POST "/publish/accounts/douyin/validate"
- test_api "41. 获取发布任务列表" GET "/publish/tasks"
- test_api "42. 创建发布任务(需有效视频)" POST "/publish/tasks" '{"videoProjectId":999,"platform":"douyin","title":"测试"}'
- test_api "43. 获取发布预览" GET "/publish/video/999/preview"
- # 其他模块
- test_api "44. 获取草稿列表" GET "/drafts"
- test_api "45. 获取通知列表" GET "/notifications"
- test_api "46. 获取播放列表" GET "/playlists"
- test_api "47. 创建播放列表" POST "/playlists" '{"name":"测试列表"}'
- test_api "48. 获取播放列表详情" GET "/playlists/1"
- test_api "49. 搜索历史" GET "/search/history?userId=1&keyword=test"
- test_api "50. 添加搜索历史" POST "/search/history" '{"userId":1,"keyword":"测试"}'
- echo -e "\n\n========== 测试完成 =========="
|