jewpms/test_menu_api.ps1
user 452f1fdbd4 refactor(database): 切换 MySQL 到 PostgreSQL 并调整相关配置
- 将数据库驱动、连接URL、依赖和Docker配置从MySQL改为PostgreSQL
- 修改liquibase配置及changelog,将boolean类型字段改为smallint或numeric以兼容PostgreSQL
- 调整SQL查询中关于IFNULL的逻辑,改用显式的NULL判断,增强兼容性
- 优化BaseRepository中SQL条件构建,加入详细SQL执行日志和参数类型输出
- 修改实体类中布尔字段的类型从Boolean/boolean改为Short,并提供对应的取值转换方法
- 更新Spring配置文件中R2DBC和Liquibase连接字符串为PostgreSQL地址
- 修正SecurityUtils中的异常处理,防止AOP错误影响安全上下文获取
- 增加LoggingAspect的执行顺序和代理暴露配置,提升日志切面功能控制
- 调整MenuResource中menus/available接口为POST,处理参数传递方式并修正数据权限条件判定
- 统一调整Liquibase changelog中timestamp类型为动态类型变量,提升各数据库兼容性
2025-09-26 22:42:21 +08:00

54 lines
1.7 KiB
PowerShell

# 测试菜单API的脚本
Write-Host "Testing Menu API with type conversion..." -ForegroundColor Green
# 测试URL
$baseUrl = "http://localhost:8080"
$menuUrl = "$baseUrl/api/menus/available"
# 构建查询参数(模拟前端发送的请求)
$params = @{
"page" = 0
"size" = 0
"sort" = "sortNo,asc"
"sort" = "id"
"number[name]" = ""
"name[name]" = ""
"path[name]" = ""
"icon[name]" = ""
"component[name]" = ""
"parentNumber[op]" = "IFNULL"
"parentNumber[value]" = ""
"visible[op]" = "="
"visible[value]" = "1" # 这是关键的测试参数
"status[op]" = "="
"status[value]" = "1" # 这也是关键的测试参数
}
# 构建URL查询字符串
$queryString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "&"
$fullUrl = "$menuUrl`?$queryString"
Write-Host "Request URL: $fullUrl" -ForegroundColor Yellow
try {
# 发送GET请求
$response = Invoke-RestMethod -Uri $fullUrl -Method Get -ContentType "application/json"
Write-Host "✅ Request successful!" -ForegroundColor Green
Write-Host "Response received with $(($response | Measure-Object).Count) items" -ForegroundColor Green
# 显示前几个结果
if ($response -and $response.Count -gt 0) {
Write-Host "First few menu items:" -ForegroundColor Cyan
$response | Select-Object -First 3 | Format-Table -AutoSize
}
} catch {
Write-Host "❌ Request failed!" -ForegroundColor Red
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
if ($_.Exception.Response) {
$statusCode = $_.Exception.Response.StatusCode
Write-Host "Status Code: $statusCode" -ForegroundColor Red
}
}
Write-Host "Test completed." -ForegroundColor Green