refactor: 整理项目根目录结构
整理内容: - 删除 60+ 临时测试输出文件 (*.txt) - 移动二进制文件到 bin/ 目录 - 移动 Shell 脚本到 scripts/ 目录 - scripts/dev/: check_gitea.sh, check_sub2api.sh, run_tests.sh - scripts/deploy/: deploy_*.sh, simple_deploy.sh - scripts/ops/: fix_nginx.sh, fix_ssl.sh, install_docker.sh - scripts/test/: test_*.sh, test_*.bat - 移动批处理文件到 scripts/ - 移动 Python 脚本到 tools/ - 清理临时日志文件 保留根目录必要文件: - go.mod, go.sum, go.work - Makefile, docker-compose.yml - .env.example, .gitignore - README.md, AGENTS.md, DEPLOY_GUIDE.md 验证: go build ./... && go test ./... 通过
This commit is contained in:
39
scripts/test/test_api.bat
Normal file
39
scripts/test/test_api.bat
Normal file
@@ -0,0 +1,39 @@
|
||||
# 用户管理系统 API 测试脚本
|
||||
|
||||
@if "%TEST_ADMIN_ACCOUNT%"=="" set TEST_ADMIN_ACCOUNT=admin
|
||||
@if "%TEST_ADMIN_PASSWORD%"=="" (
|
||||
@echo 请先设置 TEST_ADMIN_PASSWORD
|
||||
@exit /b 1
|
||||
)
|
||||
|
||||
## 1. 健康检查
|
||||
@echo "=== 1. 健康检查 ==="
|
||||
curl http://localhost:8080/health
|
||||
echo.
|
||||
|
||||
## 2. 用户注册
|
||||
@echo.
|
||||
@echo "=== 2. 用户注册 ==="
|
||||
curl -X POST http://localhost:8080/api/v1/auth/register ^
|
||||
-H "Content-Type: application/json" ^
|
||||
-d "{\"username\":\"testuser\",\"password\":\"Test123456\",\"email\":\"test@example.com\"}"
|
||||
echo.
|
||||
|
||||
## 3. 用户登录
|
||||
@echo.
|
||||
@echo "=== 3. 用户登录(admin) ==="
|
||||
curl -X POST http://localhost:8080/api/v1/auth/login ^
|
||||
-H "Content-Type: application/json" ^
|
||||
-d "{\"account\":\"%TEST_ADMIN_ACCOUNT%\",\"password\":\"%TEST_ADMIN_PASSWORD%\"}"
|
||||
echo.
|
||||
|
||||
## 4. 获取用户信息(需要token,这里先跳过)
|
||||
@echo.
|
||||
@echo "=== 4. 需要使用登录返回的token ==="
|
||||
@echo "请复制上面登录返回的access_token,然后手动测试:"
|
||||
@echo "curl -X GET http://localhost:8080/api/v1/auth/userinfo -H \"Authorization: Bearer YOUR_TOKEN\""
|
||||
echo.
|
||||
|
||||
@echo.
|
||||
@echo "测试完成!"
|
||||
@pause
|
||||
Reference in New Issue
Block a user