项目重构: 整理目录结构, 更新前后端代码, 添加测试和数据库迁移

This commit is contained in:
AIGC Developer
2025-12-30 10:24:19 +08:00
parent 5344148a1c
commit 38630dbb66
117 changed files with 1987 additions and 1316 deletions

View File

@@ -0,0 +1,51 @@
# 检查队列状态的PowerShell脚本
Write-Host "=== 检查应用状态 ===" -ForegroundColor Green
$port8080 = netstat -ano | findstr :8080
if ($port8080) {
Write-Host "✅ 应用正在运行 (端口8080)" -ForegroundColor Green
} else {
Write-Host "❌ 应用未运行 (端口8080)" -ForegroundColor Red
}
Write-Host "`n=== 检查Java进程 ===" -ForegroundColor Green
$javaProcesses = Get-Process | Where-Object {$_.ProcessName -like "*java*"}
if ($javaProcesses) {
Write-Host "✅ 找到Java进程:" -ForegroundColor Green
$javaProcesses | Select-Object Id, ProcessName, CPU | Format-Table
} else {
Write-Host "❌ 没有找到Java进程" -ForegroundColor Red
}
Write-Host "`n=== 尝试启动应用 ===" -ForegroundColor Yellow
try {
Write-Host "启动Spring Boot应用..." -ForegroundColor Yellow
Start-Process -FilePath "java" -ArgumentList "-jar", "target/demo-0.0.1-SNAPSHOT.jar", "--spring.profiles.active=dev" -WindowStyle Hidden
Write-Host "✅ 应用启动命令已执行" -ForegroundColor Green
Write-Host "等待应用启动..." -ForegroundColor Yellow
Start-Sleep -Seconds 30
Write-Host "`n=== 检查应用是否启动成功 ===" -ForegroundColor Green
$port8080After = netstat -ano | findstr :8080
if ($port8080After) {
Write-Host "✅ 应用启动成功" -ForegroundColor Green
Write-Host "`n=== 测试诊断接口 ===" -ForegroundColor Green
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/diagnostic/queue-status" -Method GET -TimeoutSec 10
Write-Host "✅ 诊断接口响应成功" -ForegroundColor Green
Write-Host "响应内容:" -ForegroundColor Yellow
$response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 3
} catch {
Write-Host "❌ 诊断接口调用失败: $($_.Exception.Message)" -ForegroundColor Red
}
} else {
Write-Host "❌ 应用启动失败" -ForegroundColor Red
}
} catch {
Write-Host "❌ 启动应用失败: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n=== 检查完成 ===" -ForegroundColor Green

View File

@@ -0,0 +1,21 @@
# 清除过期JWT Token脚本
echo "=== 清除过期JWT Token ==="
echo "问题JWT token已过期导致登录后立即被重定向"
echo "解决清除localStorage中的过期token重新登录"
echo -e "\n🔧 解决方案:"
echo "1. 打开浏览器开发者工具 (F12)"
echo "2. 进入 Console 标签页"
echo "3. 执行以下命令清除过期token"
echo ""
echo "localStorage.removeItem('token')"
echo "localStorage.removeItem('user')"
echo "location.reload()"
echo ""
echo "4. 然后重新登录:"
echo " - 用户名: admin"
echo " - 密码: admin123"
echo ""
echo "✅ JWT过期时间已从24小时增加到7天"
echo "✅ 清除过期token后重新登录即可正常工作"

View File

@@ -0,0 +1,24 @@
# 清除旧localStorage数据脚本
echo "=== 清除旧localStorage数据 ==="
echo "已修改token存储方式从localStorage改为sessionStorage"
echo "现在关闭页面时token会自动清除"
echo -e "\n🔧 清除步骤:"
echo "1. 打开浏览器开发者工具 (F12)"
echo "2. 进入 Console 标签页"
echo "3. 执行以下命令清除旧的localStorage数据"
echo ""
echo "localStorage.removeItem('token')"
echo "localStorage.removeItem('user')"
echo "console.log('已清除localStorage中的旧数据')"
echo ""
echo "4. 然后重新登录:"
echo " - 用户名: admin"
echo " - 密码: admin123"
echo ""
echo "✅ 修改内容:"
echo "- token和用户信息现在存储在sessionStorage中"
echo "- 关闭页面时自动清除,提高安全性"
echo "- 刷新页面时保持登录状态"
echo "- 401错误时自动清除sessionStorage"

View File

@@ -0,0 +1,73 @@
@echo off
chcp 65001 >nul
echo ========================================
echo PayPal配置一键设置脚本
echo ========================================
echo.
set CONFIG_FILE=src\main\resources\application-dev.properties
set SOURCE_FILE=application.properties.paypal-config
echo [1/3] 检查配置文件...
if exist "%SOURCE_FILE%" (
echo ✓ 找到PayPal配置文件
) else (
echo ✗ 配置文件不存在: %SOURCE_FILE%
echo 请确保 application.properties.paypal-config 文件存在
pause
exit /b 1
)
echo.
echo [2/3] 创建application-dev.properties...
if not exist "src\main\resources" (
mkdir src\main\resources
)
if exist "%CONFIG_FILE%" (
echo ! application-dev.properties 已存在
set /p OVERWRITE="是否追加PayPal配置(Y/N): "
if /i "%OVERWRITE%"=="Y" (
echo. >> "%CONFIG_FILE%"
type "%SOURCE_FILE%" >> "%CONFIG_FILE%"
echo ✓ PayPal配置已追加
) else (
echo - 跳过配置
)
) else (
type "%SOURCE_FILE%" > "%CONFIG_FILE%"
echo ✓ application-dev.properties 创建成功
)
echo.
echo [3/3] 验证配置...
if exist "%CONFIG_FILE%" (
echo ✓ 配置文件存在: %CONFIG_FILE%
findstr /c:"paypal.client-id" "%CONFIG_FILE%" >nul
if %errorlevel%==0 (
echo ✓ PayPal配置已添加
) else (
echo ✗ PayPal配置未找到
)
) else (
echo ✗ 配置文件创建失败
pause
exit /b 1
)
echo.
echo ========================================
echo ✓ PayPal配置完成
echo ========================================
echo.
echo 下一步:
echo 1. 启动应用: mvn spring-boot:run
echo 2. 查看日志确认PayPal初始化成功
echo 3. 访问 http://localhost:8080/swagger-ui.html 查看API文档
echo.
echo 安全提醒:
echo - application-dev.properties 已在 .gitignore 中
echo - 不会被提交到版本控制系统
echo - 请妥善保管你的PayPal凭证
echo.
pause

View File

@@ -0,0 +1,36 @@
@echo off
chcp 65001 >nul
echo ====================================
echo 启动 FRP 客户端
echo ====================================
echo.
REM 检查 frpc.ini 是否存在
if not exist "frpc.ini" (
echo [错误] frpc.ini 配置文件不存在!
echo 请先创建 frpc.ini 配置文件
echo 可以参考 frpc.ini.example 文件
pause
exit /b 1
)
REM 检查 frpc.exe 是否存在
if not exist "frpc.exe" (
echo [错误] frpc.exe 不存在!
echo 请先下载 FRP 客户端:
echo https://github.com/fatedier/frp/releases
echo 解压后,将 frpc.exe 放在当前目录
pause
exit /b 1
)
echo 正在启动 FRP 客户端...
echo 配置文件: frpc.ini
echo.
REM 启动 FRP 客户端
frpc.exe -c frpc.ini
pause

View File

@@ -0,0 +1,33 @@
@echo off
chcp 65001 >nul
echo ========================================
echo AIGC 项目本地启动脚本
echo ========================================
echo.
echo [1/2] 启动后端服务...
start "后端服务" cmd /k ".\mvnw.cmd spring-boot:run"
timeout /t 3 /nobreak >nul
echo [2/2] 启动前端服务...
cd frontend
start "前端服务" cmd /k "npm run dev"
cd ..
echo.
echo ========================================
echo 启动完成!
echo ========================================
echo.
echo 访问地址:
echo 前端: http://localhost:5173
echo 后端: http://localhost:8080
echo Swagger: http://localhost:8080/swagger-ui.html
echo.
echo 提示:
echo - 后端首次启动需要 30-60 秒
echo - 请等待服务完全启动后再访问
echo - 关闭窗口即可停止服务
echo.
pause

View File

@@ -0,0 +1,33 @@
# 启动Spring Boot应用修复DNS解析问题
# 添加JVM参数禁用DNS负缓存
Write-Host "=== 启动Spring Boot应用带DNS修复 ===" -ForegroundColor Green
$jvmArgs = @(
"-Dsun.net.inetaddr.ttl=60", # DNS成功缓存60秒
"-Dsun.net.inetaddr.negative.ttl=10", # DNS失败缓存10秒默认10分钟
"-Dnetworkaddress.cache.ttl=60", # 另一种DNS缓存设置
"-Dnetworkaddress.cache.negative.ttl=10", # 另一种DNS负缓存设置
"-jar",
"target/demo-0.0.1-SNAPSHOT.jar",
"--spring.profiles.active=dev"
)
Write-Host "启动参数: java $($jvmArgs -join ' ')" -ForegroundColor Yellow
try {
Start-Process -FilePath "java" -ArgumentList $jvmArgs -NoNewWindow -Wait:$false
Write-Host "✅ 应用启动命令已执行" -ForegroundColor Green
Write-Host "等待应用启动..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
# 检查是否启动成功
$port8080 = netstat -ano | findstr :8080
if ($port8080) {
Write-Host "✅ 应用已启动 (端口8080)" -ForegroundColor Green
} else {
Write-Host "⚠ 应用可能还在启动中,请稍后检查日志" -ForegroundColor Yellow
}
} catch {
Write-Host "❌ 启动失败: $($_.Exception.Message)" -ForegroundColor Red
}

View File

@@ -0,0 +1,84 @@
# PayPal支付测试脚本
# 使用方法: .\test-paypal-payment.ps1
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "PayPal支付功能测试" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 检查应用是否运行
Write-Host "[1/4] 检查应用状态..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/actuator/health" -TimeoutSec 3 -ErrorAction SilentlyContinue
Write-Host "✓ 应用正在运行" -ForegroundColor Green
} catch {
Write-Host "✗ 应用未启动,请先运行: mvn spring-boot:run" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "[2/4] 创建PayPal支付..." -ForegroundColor Yellow
# 生成随机订单号
$orderId = "TEST" + (Get-Date -Format "yyyyMMddHHmmss")
$body = @{
username = "testuser"
orderId = $orderId
amount = "10.00"
method = "PAYPAL"
} | ConvertTo-Json
try {
$result = Invoke-RestMethod -Uri "http://localhost:8080/api/payment/paypal/create" `
-Method Post `
-ContentType "application/json" `
-Body $body
Write-Host "✓ 支付创建成功!" -ForegroundColor Green
Write-Host ""
Write-Host "支付信息:" -ForegroundColor Cyan
Write-Host " Payment ID: $($result.paymentId)" -ForegroundColor White
Write-Host " 订单号: $orderId" -ForegroundColor White
Write-Host " 金额: $10.00 USD" -ForegroundColor White
Write-Host " PayPal Payment ID: $($result.externalTransactionId)" -ForegroundColor White
Write-Host ""
Write-Host "[3/4] 支付URL已生成" -ForegroundColor Yellow
Write-Host " $($result.paymentUrl)" -ForegroundColor Cyan
Write-Host ""
Write-Host "[4/4] 下一步操作:" -ForegroundColor Yellow
Write-Host " 1. 在浏览器中打开上面的URL" -ForegroundColor White
Write-Host " 2. 使用PayPal Sandbox测试账号登录" -ForegroundColor White
Write-Host " 3. 点击 'Pay Now' 完成支付" -ForegroundColor White
Write-Host " 4. 支付完成后会自动跳转回应用" -ForegroundColor White
Write-Host ""
# 询问是否自动打开浏览器
$open = Read-Host "是否在浏览器中打开支付URL? (Y/N)"
if ($open -eq "Y" -or $open -eq "y") {
Start-Process $result.paymentUrl
Write-Host "✓ 已在浏览器中打开支付页面" -ForegroundColor Green
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "提示:" -ForegroundColor Yellow
Write-Host "- 如果还没有创建Sandbox测试账号请访问" -ForegroundColor White
Write-Host " https://developer.paypal.com/dashboard/accounts" -ForegroundColor Cyan
Write-Host "- 创建 Personal 账号作为买家" -ForegroundColor White
Write-Host "- 使用该账号登录并完成支付测试" -ForegroundColor White
Write-Host "========================================" -ForegroundColor Cyan
} catch {
Write-Host "✗ 创建支付失败" -ForegroundColor Red
Write-Host "错误信息: $($_.Exception.Message)" -ForegroundColor Red
Write-Host ""
Write-Host "可能的原因:" -ForegroundColor Yellow
Write-Host "1. PayPal配置未正确加载" -ForegroundColor White
Write-Host "2. PayPal Client ID或Secret不正确" -ForegroundColor White
Write-Host "3. 网络连接问题" -ForegroundColor White
Write-Host ""
Write-Host "请检查应用日志获取详细错误信息" -ForegroundColor Yellow
}