@echo off
chcp 65001 > nul
echo ========================================
echo 员工实体关系员工姓名字段测试
echo ========================================
echo.

REM 获取 token
echo [1/5] 获取登录 token...
curl -s -X POST "http://localhost:8080/login/test" \
  -H "Content-Type: application/json" \
  -d "{\"username\":\"admin\",\"password\":\"admin123\"}" \
  > token_response.json

for /f "tokens=2 delims=:\"" %%a in ('findstr "\"token\"" token_response.json') do set TOKEN=%%a
echo Token: %TOKEN%
echo.

REM 测试列表接口
echo [2/5] 测试列表接口...
curl -s -X GET "http://localhost:8080/ccdi/staffEnterpriseRelation/list?pageNum=1&pageSize=10" \
  -H "Authorization: Bearer %TOKEN%" \
  > list_response.json

echo 检查 personName 字段是否在响应中...
findstr /C:"personName" list_response.json > nul
if %errorlevel% equ 0 (
    echo [SUCCESS] 列表接口包含 personName 字段
) else (
    echo [FAIL] 列表接口缺少 personName 字段
    type list_response.json
)
echo.

REM 测试详情接口
echo [3/5] 测试详情接口 (ID: 1)...
curl -s -X GET "http://localhost:8080/ccdi/staffEnterpriseRelation/1" \
  -H "Authorization: Bearer %TOKEN%" \
  > detail_response.json

echo 检查 personName 字段是否在响应中...
findstr /C:"personName" detail_response.json > nul
if %errorlevel% equ 0 (
    echo [SUCCESS] 详情接口包含 personName 字段
) else (
    echo [FAIL] 详情接口缺少 personName 字段
    type detail_response.json
)
echo.

REM 查看响应内容
echo [4/5] 查看列表响应内容...
type list_response.json
echo.
echo ========================================
echo 测试完成
echo ========================================

pause
