员工信息管理
- 新增员工信息CRUD功能 - 添加员工关联人员管理 - 配置MyBatis Plus审计字段 - 添加OpenSpec规范文档 - 新增测试脚本和数据 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
80
test/batch_insert.ps1
Normal file
80
test/batch_insert.ps1
Normal file
@@ -0,0 +1,80 @@
|
||||
# 批量插入100条员工数据
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
$BASE_URL = "http://localhost:8080"
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "批量插入100条员工数据" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# 登录获取 Token
|
||||
Write-Host "[1] 正在登录..." -ForegroundColor Yellow
|
||||
$loginBody = @{
|
||||
username = "admin"
|
||||
password = "admin123"
|
||||
} | ConvertTo-Json
|
||||
|
||||
$loginResponse = Invoke-RestMethod -Uri "$BASE_URL/login/test" -Method Post -ContentType "application/json; charset=utf-8" -Body ([System.Text.Encoding]::UTF8.GetBytes($loginBody))
|
||||
$TOKEN = $loginResponse.token
|
||||
|
||||
Write-Host "登录成功" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
$headers = @{
|
||||
"Authorization" = "Bearer $TOKEN"
|
||||
"Content-Type" = "application/json; charset=utf-8"
|
||||
}
|
||||
|
||||
# 批量插入100条数据
|
||||
Write-Host "[2] 开始批量插入100条员工数据..." -ForegroundColor Yellow
|
||||
|
||||
$successCount = 0
|
||||
$failCount = 0
|
||||
|
||||
for ($i = 1; $i -le 100; $i++) {
|
||||
try {
|
||||
$tellerNo = "TEST" + $i.ToString("000")
|
||||
$idCard = "110101199001011" + ($i + 200).ToString("000")
|
||||
|
||||
$addBody = @{
|
||||
name = "测试员工" + $i
|
||||
tellerNo = $tellerNo
|
||||
orgNo = "1001"
|
||||
idCard = $idCard
|
||||
phone = "13800138" + ($i % 100).ToString("00")
|
||||
status = "0"
|
||||
relatives = @(
|
||||
@{
|
||||
relativeName = "亲属" + $i + "A"
|
||||
relativeIdCard = "110101199001011" + ($i + 300).ToString("000")
|
||||
relativePhone = "13900138" + ($i % 100).ToString("00")
|
||||
relationship = "配偶"
|
||||
}
|
||||
)
|
||||
} | ConvertTo-Json -Depth 10
|
||||
|
||||
$bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($addBody)
|
||||
$response = Invoke-RestMethod -Uri "$BASE_URL/dpc/employee" -Method Post -Headers $headers -Body $bodyBytes
|
||||
|
||||
if ($response.code -eq 200) {
|
||||
$successCount++
|
||||
Write-Host "[$i/100] 插入成功: 测试员工$i" -ForegroundColor Green
|
||||
} else {
|
||||
$failCount++
|
||||
Write-Host "[$i/100] 插入失败: $($response.msg)" -ForegroundColor Red
|
||||
}
|
||||
} catch {
|
||||
$failCount++
|
||||
Write-Host "[$i/100] 插入异常: $_" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "插入完成" -ForegroundColor Cyan
|
||||
Write-Host "成功: $successCount 条" -ForegroundColor Green
|
||||
Write-Host "失败: $failCount 条" -ForegroundColor Red
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Read-Host "按回车键退出"
|
||||
Reference in New Issue
Block a user