修复指尖管理师上线配置

This commit is contained in:
2026-06-22 20:39:51 +08:00
parent 9400e53fe9
commit a53b27ef20
7 changed files with 425 additions and 459 deletions
+22 -21
View File
@@ -4,91 +4,91 @@ spring:
routes: routes:
# 前台API路由 # 前台API路由
- id: product-route - id: product-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/product/** - Path=/api/product/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: product-like-route - id: product-like-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/product-like/** - Path=/api/product-like/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: shop-route - id: shop-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/shop/** - Path=/api/shop/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: user-route - id: user-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/user/** - Path=/api/user/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: comment-route - id: comment-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/comment/** - Path=/api/comment/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: balance-route - id: balance-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/balance/** - Path=/api/balance/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: tag-route - id: tag-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/tag/** - Path=/api/tag/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: file-route - id: file-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/file/** - Path=/api/file/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: permission-route - id: permission-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/permission/** - Path=/api/permission/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: coupon-route - id: coupon-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/coupon/** - Path=/api/coupon/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: cart-route - id: cart-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/cart/** - Path=/api/cart/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: order-route - id: order-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/order/** - Path=/api/order/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: wishlist-route - id: wishlist-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/wishlist/** - Path=/api/wishlist/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: nail-artist-route - id: nail-artist-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/nail-artist/** - Path=/api/nail-artist/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
- id: legal-agreement-route - id: legal-agreement-route
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/legal-agreement/** - Path=/api/legal-agreement/**
filters: filters:
@@ -96,7 +96,7 @@ spring:
# 后台管理API路由(/api/admin/** 格式) # 后台管理API路由(/api/admin/** 格式)
- id: admin-api-route - id: admin-api-route
order: -10 order: -10
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/admin/** - Path=/api/admin/**
filters: filters:
@@ -104,29 +104,29 @@ spring:
# 后台管理API路由(/admin/api/** 格式) # 后台管理API路由(/admin/api/** 格式)
- id: admin-route - id: admin-route
order: -9 order: -9
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/admin/api/** - Path=/admin/api/**
filters: filters:
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining} - RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
- id: admin-auth-compat-route - id: admin-auth-compat-route
order: -8 order: -8
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/admin/auth/** - Path=/admin/auth/**
# 前台API兜底路由,避免 Core 新增模块后 Gateway 未同步导致 404 # 前台API兜底路由,避免 Core 新增模块后 Gateway 未同步导致 404
- id: frontend-fallback-route - id: frontend-fallback-route
order: 100 order: 100
uri: lb://yumi-nail-core uri: lb://fingertip-designer-core
predicates: predicates:
- Path=/api/** - Path=/api/**
filters: filters:
- RewritePath=/api/(?<remaining>.*), /${remaining} - RewritePath=/api/(?<remaining>.*), /${remaining}
yuminail: fingertip-designer:
security: security:
jwt: jwt:
issuer: yuminail issuer: fingertip-designer
clock-skew-seconds: 30 clock-skew-seconds: 30
gateway: gateway:
whitelist: whitelist:
@@ -150,6 +150,7 @@ yuminail:
- /api/admin/auth/login - /api/admin/auth/login
- /api/admin/auth/login-shops/** - /api/admin/auth/login-shops/**
- /api/admin/auth/refresh - /api/admin/auth/refresh
- /api/admin/auth/register
- /admin/auth/login - /admin/auth/login
- /admin/auth/login-shops/** - /admin/auth/login-shops/**
- /admin/auth/refresh - /admin/auth/refresh
+1 -1
View File
@@ -7,7 +7,7 @@
"include": [] "include": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": true,
"es6": true, "es6": true,
"enhance": true, "enhance": true,
"postcss": true, "postcss": true,
+3 -3
View File
@@ -1,7 +1,7 @@
const DEFAULT_DOMAIN = 'http://127.0.0.1:63341' const DEFAULT_DOMAIN = 'https://yunail.art'
module.exports = { module.exports = {
API_DOMAIN: DEFAULT_DOMAIN, API_DOMAIN: `${DEFAULT_DOMAIN}/api`,
ADMIN_API_BASE_URL: `${DEFAULT_DOMAIN}/admin`, ADMIN_API_BASE_URL: `${DEFAULT_DOMAIN}/api/admin`,
REQUEST_TIMEOUT: 10000 REQUEST_TIMEOUT: 10000
} }
+196 -338
View File
@@ -10,19 +10,19 @@ param(
[switch]$SkipDatabaseInit, [switch]$SkipDatabaseInit,
[string]$DatabaseTargetName = "mysql02", [string]$DatabaseTargetName = "mysql02",
[int]$DatabasePort = 3306, [int]$DatabasePort = 3306,
[string]$DatabaseName = "nailart", [string]$DatabaseName = "FingertipDesigner",
[string]$DatabaseUser = "", [string]$DatabaseUser = "",
[string]$DatabasePassword = "", [string]$DatabasePassword = "",
[string]$InitSqlPath = "", [string]$InitSqlPath = "",
[string]$CorePattern = "^YumiNail-Core", [string]$CorePattern = "^FD-Core",
[string]$GatewayPattern = "^YumiNail-Gateway", [string]$GatewayPattern = "^FD-Gateway",
[string]$WebTargetName = "", [string]$WebTargetName = "",
[string]$WebTargetHost = "8.137.35.61", [string]$WebTargetHost = "8.137.35.61",
[string]$CoreRemoteAppDir = "/opt/yuminail-core", [string]$CoreRemoteAppDir = "/opt/fingertip-designer-core",
[string]$GatewayRemoteAppDir = "/opt/yuminail-gateway", [string]$GatewayRemoteAppDir = "/opt/fingertip-designer-gateway",
[string]$WebRemoteDir = "/opt/yuminail-frontend", [string]$WebRemoteDir = "/opt/fingertip-designer-frontend",
[string]$CoreServiceName = "yuminail-core", [string]$CoreServiceName = "fingertip-designer-core",
[string]$GatewayServiceName = "yuminail-gateway", [string]$GatewayServiceName = "fingertip-designer-gateway",
[int]$CoreHealthPort = 81, [int]$CoreHealthPort = 81,
[int]$GatewayHealthPort = 80, [int]$GatewayHealthPort = 80,
[string]$HealthPath = "/health/check", [string]$HealthPath = "/health/check",
@@ -33,58 +33,93 @@ param(
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$ReleaseTimestamp = Get-Date -Format "yyyyMMdd-HHmmss" $releaseTimestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$ResolvedRepoRoot = (Resolve-Path -LiteralPath $RepoRoot).Path $resolvedRepoRoot = (Resolve-Path -LiteralPath $RepoRoot).Path
$ReleaseRoot = Join-Path $ResolvedRepoRoot "artifacts\release" $releaseRoot = Join-Path $resolvedRepoRoot "artifacts\release"
$ReleaseDir = Join-Path $ReleaseRoot $ReleaseTimestamp $releaseDir = Join-Path $releaseRoot $releaseTimestamp
$BackendDir = Join-Path $ReleaseDir "backend" $backendDir = Join-Path $releaseDir "backend"
$FrontendDir = Join-Path $ReleaseDir "frontend" $frontendDir = Join-Path $releaseDir "frontend"
$SqlDir = Join-Path $ReleaseDir "sql" $sqlDir = Join-Path $releaseDir "sql"
$ManifestPath = Join-Path $ReleaseDir "manifest.json" $manifestPath = Join-Path $releaseDir "manifest.json"
$DefaultInitSqlPath = Join-Path $ResolvedRepoRoot "YumiNail-Core\src\main\resources\files\YumiNail.sql" $defaultInitSqlPath = Join-Path $resolvedRepoRoot "scripts\sql\init\YumiNail.sql"
if (-not $InitSqlPath) { if (-not $InitSqlPath) {
$InitSqlPath = $DefaultInitSqlPath $InitSqlPath = $defaultInitSqlPath
} }
function Write-Step { function Write-Step {
param([string]$Message) param([string]$Message)
Write-Host "" Write-Host ""
Write-Host "==> $Message" Write-Host "==> $Message"
} }
function Resolve-ServerInfoPath {
param([string]$ExplicitPath)
if ($ExplicitPath) {
if (-not (Test-Path -LiteralPath $ExplicitPath)) {
throw "Server workbook not found: $ExplicitPath"
}
return (Resolve-Path -LiteralPath $ExplicitPath).Path
}
$codeRoot = "Y:\code"
if (-not (Test-Path -LiteralPath $codeRoot)) {
throw "Server workbook path was not provided and $codeRoot does not exist."
}
$workbooks = @(Get-ChildItem -LiteralPath $codeRoot -Filter "*.xlsx" -File | Sort-Object LastWriteTime -Descending)
if ($workbooks.Count -eq 0) {
throw "No .xlsx server workbook found under $codeRoot. Pass -ServerInfoPath explicitly."
}
return $workbooks[0].FullName
}
function ConvertTo-BashSingleQuoted { function ConvertTo-BashSingleQuoted {
param([AllowNull()][string]$Value) param([AllowNull()][string]$Value)
if ($null -eq $Value) { if ($null -eq $Value) {
$Value = "" $Value = ""
} }
return "'" + $Value.Replace("'", "'""'""'") + "'" return "'" + $Value.Replace("'", "'""'""'") + "'"
} }
function Resolve-Maven {
param([string]$PreferredPath)
if ($PreferredPath -and (Test-Path -LiteralPath $PreferredPath)) {
return (Resolve-Path -LiteralPath $PreferredPath).Path
}
$fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
$fromPath = Get-Command mvn -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
throw "找不到 Maven,请通过 -MavenPath 传入 Maven 可执行文件绝对路径。"
}
function Invoke-Native {
param(
[string]$FilePath,
[string[]]$Arguments,
[string]$WorkingDirectory = "",
[switch]$RemoteMutation,
[switch]$Sensitive
)
if ($Sensitive) {
Write-Host ">> $FilePath <敏感参数已隐藏>"
}
else {
Write-Host ">> $FilePath $($Arguments -join ' ')"
}
if ($DryRun -and $RemoteMutation) {
return
}
$previousLocation = Get-Location
try {
if ($WorkingDirectory) {
Set-Location -LiteralPath $WorkingDirectory
}
& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "命令执行失败,退出码 ${LASTEXITCODE}:$FilePath"
}
}
finally {
Set-Location $previousLocation
}
}
function Read-ZipEntryText { function Read-ZipEntryText {
param($Zip, [string]$Name) param($Zip, [string]$Name)
$entry = $Zip.GetEntry($Name) $entry = $Zip.GetEntry($Name)
if (-not $entry) { if (-not $entry) {
return $null return $null
@@ -107,6 +142,7 @@ function Read-ZipEntryText {
function Get-RelationshipId { function Get-RelationshipId {
param($Element) param($Element)
foreach ($attribute in $Element.Attributes) { foreach ($attribute in $Element.Attributes) {
if ($attribute.LocalName -eq "id") { if ($attribute.LocalName -eq "id") {
return $attribute.Value return $attribute.Value
@@ -117,6 +153,7 @@ function Get-RelationshipId {
function Get-ColumnIndex { function Get-ColumnIndex {
param([string]$CellRef) param([string]$CellRef)
$letters = ([regex]::Match($CellRef, "^[A-Z]+")).Value $letters = ([regex]::Match($CellRef, "^[A-Z]+")).Value
$index = 0 $index = 0
foreach ($character in $letters.ToCharArray()) { foreach ($character in $letters.ToCharArray()) {
@@ -144,7 +181,7 @@ function Get-XlsxFirstSheetRows {
[xml]$relsXml = Read-ZipEntryText $zip "xl/_rels/workbook.xml.rels" [xml]$relsXml = Read-ZipEntryText $zip "xl/_rels/workbook.xml.rels"
$firstSheet = $workbookXml.GetElementsByTagName("sheet").Item(0) $firstSheet = $workbookXml.GetElementsByTagName("sheet").Item(0)
if (-not $firstSheet) { if (-not $firstSheet) {
throw "Workbook has no sheets: $Path" throw "服务器清单没有工作表:$Path"
} }
$relationshipId = Get-RelationshipId $firstSheet $relationshipId = Get-RelationshipId $firstSheet
@@ -156,7 +193,7 @@ function Get-XlsxFirstSheetRows {
} }
} }
if (-not $relationship) { if (-not $relationship) {
throw "Cannot resolve workbook relationship $relationshipId" throw "无法解析工作表关系:$relationshipId"
} }
$target = $relationship.Target $target = $relationship.Target
@@ -197,8 +234,8 @@ function Get-XlsxFirstSheetRows {
} }
if ($maxIndex -gt 0) { if ($maxIndex -gt 0) {
$values = for ($i = 1; $i -le $maxIndex; $i++) { $values = for ($index = 1; $index -le $maxIndex; $index++) {
if ($valuesByIndex.ContainsKey($i)) { $valuesByIndex[$i] } else { "" } if ($valuesByIndex.ContainsKey($index)) { $valuesByIndex[$index] } else { "" }
} }
if (($values -join "").Trim()) { if (($values -join "").Trim()) {
$rows += ,$values $rows += ,$values
@@ -216,12 +253,12 @@ function Get-ServersFromWorkbook {
param([string]$Path) param([string]$Path)
if (-not (Test-Path -LiteralPath $Path)) { if (-not (Test-Path -LiteralPath $Path)) {
throw "Server workbook not found: $Path" throw "服务器清单不存在:$Path"
} }
$rows = @(Get-XlsxFirstSheetRows (Resolve-Path -LiteralPath $Path).Path) $rows = @(Get-XlsxFirstSheetRows (Resolve-Path -LiteralPath $Path).Path)
if ($rows.Count -lt 2) { if ($rows.Count -lt 2) {
throw "Server workbook has no data rows: $Path" throw "服务器清单没有数据行:$Path"
} }
foreach ($row in $rows[1..($rows.Count - 1)]) { foreach ($row in $rows[1..($rows.Count - 1)]) {
@@ -241,96 +278,46 @@ function Get-ServersFromWorkbook {
} }
} }
function Resolve-ServerInfoPath {
param([string]$ExplicitPath)
if ($ExplicitPath) {
if (-not (Test-Path -LiteralPath $ExplicitPath)) {
throw "服务器清单不存在:$ExplicitPath"
}
return (Resolve-Path -LiteralPath $ExplicitPath).Path
}
$codeRoot = "Y:\code"
if (-not (Test-Path -LiteralPath $codeRoot)) {
throw "未传入 -ServerInfoPath,且默认目录不存在:$codeRoot"
}
$workbooks = @(Get-ChildItem -LiteralPath $codeRoot -Filter "*.xlsx" -File | Sort-Object LastWriteTime -Descending)
if ($workbooks.Count -eq 0) {
throw "默认目录下没有服务器清单 xlsx,请显式传入 -ServerInfoPath。"
}
return $workbooks[0].FullName
}
function Assert-ProductionTarget { function Assert-ProductionTarget {
param([object[]]$Servers) param([object[]]$Servers)
$blocked = @($Servers | Where-Object { $_.Name -match "^(?i:MessageHub|mysql|nacos|redis|rabbitmq)" }) $blocked = @($Servers | Where-Object { $_.Name -match "^(?i:MessageHub|mysql|nacos|redis|rabbitmq)" })
if ($blocked.Count -gt 0) { if ($blocked.Count -gt 0) {
throw "Refusing to deploy to infrastructure or non-YumiNail rows: $($blocked.Name -join ', ')" throw "拒绝把应用发布到基础设施节点:$($blocked.Name -join ', ')"
} }
$knownNonProduction = @($Servers | Where-Object { $_.Environment -match "(?i)\b(dev|test|local|staging)\b" }) $knownNonProduction = @($Servers | Where-Object { $_.Environment -match "(?i)\b(dev|test|local|staging)\b" })
if ($knownNonProduction.Count -gt 0) { if ($knownNonProduction.Count -gt 0) {
throw "Refusing to deploy to rows marked as non-production: $($knownNonProduction.Name -join ', ')" throw "拒绝发布到非生产环境节点:$($knownNonProduction.Name -join ', ')"
}
}
function Resolve-Maven {
param([string]$PreferredPath)
if ($PreferredPath -and (Test-Path -LiteralPath $PreferredPath)) {
return (Resolve-Path -LiteralPath $PreferredPath).Path
}
$fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
$fromPath = Get-Command mvn -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
$fallback = "D:\开发\apache-maven-3.9.9\bin\mvn.cmd"
if (Test-Path -LiteralPath $fallback) {
return $fallback
}
throw "Cannot find Maven. Pass -MavenPath with an absolute Maven executable path."
}
function Invoke-Native {
param(
[string]$FilePath,
[string[]]$Arguments,
[string]$WorkingDirectory = "",
[switch]$RemoteMutation,
[switch]$Sensitive
)
if ($Sensitive) {
Write-Host ">> $FilePath <sensitive arguments omitted>"
}
else {
$displayArguments = @()
for ($index = 0; $index -lt $Arguments.Count; $index++) {
$argument = $Arguments[$index]
if ($argument -eq "-pw") {
$displayArguments += $argument
if (($index + 1) -lt $Arguments.Count) {
$displayArguments += "***"
$index++
}
}
else {
$displayArguments += $argument
}
}
Write-Host ">> $FilePath $($displayArguments -join ' ')"
}
if ($DryRun -and $RemoteMutation) {
return
}
$previousLocation = Get-Location
try {
if ($WorkingDirectory) {
Set-Location -LiteralPath $WorkingDirectory
}
& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "Command failed with exit code ${LASTEXITCODE}: $FilePath"
}
}
finally {
Set-Location $previousLocation
} }
} }
function Get-SshTarget { function Get-SshTarget {
param([object]$Server) param([object]$Server)
return "$($Server.User)@$($Server.Host)" return "$($Server.User)@$($Server.Host)"
} }
@@ -344,7 +331,7 @@ function Invoke-RemoteShell {
if ($UsePuttyPassword) { if ($UsePuttyPassword) {
$plink = Get-Command plink -ErrorAction SilentlyContinue $plink = Get-Command plink -ErrorAction SilentlyContinue
if ((-not $DryRun) -and (-not $plink)) { if ((-not $DryRun) -and (-not $plink)) {
throw "PuTTY plink not found. Install PuTTY tools or configure SSH keys and omit -UsePuttyPassword." throw "找不到 PuTTY plink,请安装 PuTTY 工具或改用 SSH key。"
} }
$plinkPath = if ($plink) { $plink.Source } else { "plink" } $plinkPath = if ($plink) { $plink.Source } else { "plink" }
Invoke-Native $plinkPath @("-batch", "-ssh", "-P", [string]$Server.Port, "-l", $Server.User, "-pw", $Server.Password, $Server.Host, $Command) -Sensitive:$Sensitive -RemoteMutation Invoke-Native $plinkPath @("-batch", "-ssh", "-P", [string]$Server.Port, "-l", $Server.User, "-pw", $Server.Password, $Server.Host, $Command) -Sensitive:$Sensitive -RemoteMutation
@@ -363,13 +350,13 @@ function Copy-FileToRemote {
) )
if (-not (Test-Path -LiteralPath $LocalPath)) { if (-not (Test-Path -LiteralPath $LocalPath)) {
throw "Local upload file not found: $LocalPath" throw "本地上传文件不存在:$LocalPath"
} }
if ($UsePuttyPassword) { if ($UsePuttyPassword) {
$pscp = Get-Command pscp -ErrorAction SilentlyContinue $pscp = Get-Command pscp -ErrorAction SilentlyContinue
if ((-not $DryRun) -and (-not $pscp)) { if ((-not $DryRun) -and (-not $pscp)) {
throw "PuTTY pscp not found. Install PuTTY tools or configure SSH keys and omit -UsePuttyPassword." throw "找不到 PuTTY pscp,请安装 PuTTY 工具或改用 SSH key。"
} }
$pscpPath = if ($pscp) { $pscp.Source } else { "pscp" } $pscpPath = if ($pscp) { $pscp.Source } else { "pscp" }
Invoke-Native $pscpPath @("-batch", "-P", [string]$Server.Port, "-pw", $Server.Password, $LocalPath, "$(Get-SshTarget $Server):$RemotePath") -Sensitive:$Sensitive -RemoteMutation Invoke-Native $pscpPath @("-batch", "-P", [string]$Server.Port, "-pw", $Server.Password, $LocalPath, "$(Get-SshTarget $Server):$RemotePath") -Sensitive:$Sensitive -RemoteMutation
@@ -379,77 +366,37 @@ function Copy-FileToRemote {
} }
} }
function Invoke-RemoteShellParallel { function Invoke-RemoteShellMany {
param( param(
[object[]]$Servers, [object[]]$Servers,
[string]$Command, [string]$Command,
[string]$GroupName [string]$GroupName
) )
if ($DryRun) {
foreach ($server in $Servers) { foreach ($server in $Servers) {
Write-Host "DryRun parallel $GroupName on $($server.Name):" Write-Host "$GroupName target: $($server.Name) $($server.User)@$($server.Host):$($server.Port)"
Invoke-RemoteShell $server $Command Invoke-RemoteShell $server $Command
} }
return
}
if ($UsePuttyPassword) {
foreach ($server in $Servers) {
Invoke-RemoteShell $server $Command -Sensitive
}
return
}
$jobs = foreach ($server in $Servers) {
Start-Job -Name "$GroupName-$($server.Name)" -ScriptBlock {
param([int]$Port, [string]$User, [string]$HostName, [string]$RemoteCommand)
& ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -p $Port "$User@$HostName" $RemoteCommand
exit $LASTEXITCODE
} -ArgumentList $server.Port, $server.User, $server.Host, $Command
}
$failed = @()
foreach ($job in $jobs) {
Wait-Job $job | Out-Null
$output = Receive-Job $job
if ($output) {
$output | ForEach-Object { Write-Host "[$($job.Name)] $_" }
}
if ($job.State -ne "Completed") {
$failed += $job.Name
}
elseif ($job.ChildJobs[0].JobStateInfo.Reason -and $job.ChildJobs[0].JobStateInfo.Reason.Message) {
$failed += $job.Name
}
Remove-Job $job -Force
}
if ($failed.Count -gt 0) {
throw "Parallel remote command failed for ${GroupName}: $($failed -join ', ')"
}
} }
function Test-GitState { function Test-GitState {
Push-Location $ResolvedRepoRoot Push-Location $resolvedRepoRoot
try { try {
$commit = (& git rev-parse HEAD).Trim() $commit = (& git rev-parse HEAD).Trim()
$branch = (& git branch --show-current).Trim() $branch = (& git branch --show-current).Trim()
$status = @(& git status --porcelain) $status = @(& git status --porcelain)
$dirty = $status.Count -gt 0 if ($status.Count -gt 0) {
if ($dirty) { Write-Warning "当前工作区有 $($status.Count) 个变更路径。"
Write-Warning "Git working tree has $($status.Count) changed paths."
$status | Select-Object -First 40 | ForEach-Object { Write-Warning $_ } $status | Select-Object -First 40 | ForEach-Object { Write-Warning $_ }
if ($Deploy -and (-not $DryRun) -and (-not $AllowDirtyWorkingTree)) { if ($Deploy -and (-not $DryRun) -and (-not $AllowDirtyWorkingTree)) {
throw "Refusing production deployment from a dirty working tree. Commit/stash first or rerun with -AllowDirtyWorkingTree." throw "拒绝从脏工作区发布生产,请先提交/暂存,或显式传入 -AllowDirtyWorkingTree。"
} }
} }
return [pscustomobject]@{ return [pscustomobject]@{
Branch = $branch Branch = $branch
Commit = $commit Commit = $commit
Dirty = $dirty Dirty = $status.Count -gt 0
ChangedPathCount = $status.Count ChangedPathCount = $status.Count
ChangedPaths = @($status)
} }
} }
finally { finally {
@@ -457,24 +404,31 @@ function Test-GitState {
} }
} }
function Test-SqlSafety { function Assert-InitSqlSafe {
param([string]$Path) param([string]$Path)
if (-not (Test-Path -LiteralPath $Path)) { if (-not (Test-Path -LiteralPath $Path)) {
throw "Init SQL not found: $Path" throw "初始化 SQL 不存在:$Path"
} }
$content = Get-Content -LiteralPath $Path -Raw $content = Get-Content -LiteralPath $Path -Raw
$dangerousMatch = [regex]::Match($content, "(?im)^\s*(drop\s+(database|schema|table)|truncate\s+table|delete\s+from)\b") if ($content -notmatch "CREATE DATABASE IF NOT EXISTS\s+FingertipDesigner") {
throw "初始化 SQL 未声明目标库 FingertipDesigner:$Path"
}
if ($content -notmatch "(?im)^\s*use\s+FingertipDesigner\s*;") {
throw "初始化 SQL 未切换到目标库 FingertipDesigner:$Path"
}
$dangerousMatch = [regex]::Match($content, "(?im)^\s*(drop\s+(database|schema|table)|truncate\s+table)\b")
if ($dangerousMatch.Success) { if ($dangerousMatch.Success) {
throw "Refusing init SQL with destructive statement near: $($dangerousMatch.Value)" throw "初始化 SQL 包含危险语句:$($dangerousMatch.Value)"
} }
} }
function Build-ReleasePackage { function Build-ReleasePackage {
param([object]$GitState) param([object]$GitState)
New-Item -ItemType Directory -Force -Path $BackendDir, $FrontendDir, $SqlDir | Out-Null New-Item -ItemType Directory -Force -Path $backendDir, $frontendDir, $sqlDir | Out-Null
$maven = Resolve-Maven $MavenPath $maven = Resolve-Maven $MavenPath
if (-not $SkipBuild) { if (-not $SkipBuild) {
@@ -483,57 +437,56 @@ function Build-ReleasePackage {
$mavenArgs += "-DskipTests" $mavenArgs += "-DskipTests"
} }
Write-Step "Build YumiNail-Core" Write-Step "构建 FD-Core"
Invoke-Native $maven $mavenArgs (Join-Path $ResolvedRepoRoot "YumiNail-Core") Invoke-Native $maven $mavenArgs (Join-Path $resolvedRepoRoot "FD-Core")
Write-Step "Build YumiNail-Gateway" Write-Step "构建 FD-Gateway"
Invoke-Native $maven $mavenArgs (Join-Path $ResolvedRepoRoot "YumiNail-Gateway") Invoke-Native $maven $mavenArgs (Join-Path $resolvedRepoRoot "FD-Gateway")
Write-Step "Build YumiNail-Frontend" Write-Step "构建 FD-Frontend"
$frontendRoot = Join-Path $ResolvedRepoRoot "YumiNail-Frontend" $frontendRoot = Join-Path $resolvedRepoRoot "FD-Frontend"
if (-not (Test-Path -LiteralPath (Join-Path $frontendRoot "node_modules"))) { if (-not (Test-Path -LiteralPath (Join-Path $frontendRoot "node_modules"))) {
Invoke-Native "npm" @("ci") $frontendRoot Invoke-Native "npm" @("ci") $frontendRoot
} }
Invoke-Native "npm" @("run", "build") $frontendRoot Invoke-Native "npm" @("run", "build") $frontendRoot
} }
$coreJar = Join-Path $ResolvedRepoRoot "YumiNail-Core\target\YumiNail-Core.jar" $coreJar = Join-Path $resolvedRepoRoot "FD-Core\target\FingertipDesigner-Core.jar"
$gatewayJar = Join-Path $ResolvedRepoRoot "YumiNail-Gateway\target\YumiNail-Gateway.jar" $gatewayJar = Join-Path $resolvedRepoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
$frontendDist = Join-Path $ResolvedRepoRoot "YumiNail-Frontend\dist" $frontendDist = Join-Path $resolvedRepoRoot "FD-Frontend\dist"
foreach ($requiredPath in @($coreJar, $gatewayJar, $frontendDist, $InitSqlPath)) { foreach ($requiredPath in @($coreJar, $gatewayJar, $frontendDist, $InitSqlPath)) {
if (-not (Test-Path -LiteralPath $requiredPath)) { if (-not (Test-Path -LiteralPath $requiredPath)) {
throw "Required release artifact is missing: $requiredPath" throw "缺少发布产物:$requiredPath"
} }
} }
$coreArtifact = Join-Path $BackendDir "YumiNail-Core.jar" $coreArtifact = Join-Path $backendDir "FingertipDesigner-Core.jar"
$gatewayArtifact = Join-Path $BackendDir "YumiNail-Gateway.jar" $gatewayArtifact = Join-Path $backendDir "FingertipDesigner-Gateway.jar"
$frontendArtifact = Join-Path $FrontendDir "yuminail-frontend-dist.tar.gz" $frontendArtifact = Join-Path $frontendDir "fingertip-designer-frontend-dist.tar.gz"
$sqlArtifact = Join-Path $SqlDir "YumiNail.sql" $sqlArtifact = Join-Path $sqlDir "YumiNail.sql"
Copy-Item -LiteralPath $coreJar -Destination $coreArtifact -Force Copy-Item -LiteralPath $coreJar -Destination $coreArtifact -Force
Copy-Item -LiteralPath $gatewayJar -Destination $gatewayArtifact -Force Copy-Item -LiteralPath $gatewayJar -Destination $gatewayArtifact -Force
Copy-Item -LiteralPath $InitSqlPath -Destination $sqlArtifact -Force Copy-Item -LiteralPath $InitSqlPath -Destination $sqlArtifact -Force
$tar = Get-Command tar -ErrorAction SilentlyContinue $tar = Get-Command tar -ErrorAction SilentlyContinue
if (-not $tar) { if (-not $tar) {
throw "tar is required to package the frontend dist archive." throw "缺少 tar,无法打包前端 dist。"
} }
if (Test-Path -LiteralPath $frontendArtifact) { if (Test-Path -LiteralPath $frontendArtifact) {
Remove-Item -LiteralPath $frontendArtifact -Force Remove-Item -LiteralPath $frontendArtifact -Force
} }
Invoke-Native $tar.Source @("-czf", $frontendArtifact, "-C", (Join-Path $ResolvedRepoRoot "YumiNail-Frontend"), "dist") Invoke-Native $tar.Source @("-czf", $frontendArtifact, "-C", (Join-Path $resolvedRepoRoot "FD-Frontend"), "dist")
$artifacts = @($coreArtifact, $gatewayArtifact, $frontendArtifact, $sqlArtifact) $hashes = foreach ($artifact in @($coreArtifact, $gatewayArtifact, $frontendArtifact, $sqlArtifact)) {
$hashes = foreach ($artifact in $artifacts) {
$hash = Get-FileHash -LiteralPath $artifact -Algorithm SHA256 $hash = Get-FileHash -LiteralPath $artifact -Algorithm SHA256
[pscustomobject]@{ [pscustomobject]@{
Path = $artifact.Replace($ResolvedRepoRoot, "").TrimStart("\", "/") Path = $artifact.Replace($resolvedRepoRoot, "").TrimStart("\", "/")
Sha256 = $hash.Hash Sha256 = $hash.Hash
} }
} }
return [pscustomobject]@{ return [pscustomobject]@{
Directory = $ReleaseDir Directory = $releaseDir
CoreJar = $coreArtifact CoreJar = $coreArtifact
GatewayJar = $gatewayArtifact GatewayJar = $gatewayArtifact
FrontendArchive = $frontendArtifact FrontendArchive = $frontendArtifact
@@ -567,7 +520,7 @@ HEALTH_PATH=$healthPath
HEALTH_PORT=$healthPortText HEALTH_PORT=$healthPortText
HEALTH_TIMEOUT=$timeout HEALTH_TIMEOUT=$timeout
RELEASE="`$APP_DIR/releases/`$RELEASE_NAME" RELEASE="`$APP_DIR/releases/`$RELEASE_NAME"
BACKUP_NAME="app-$ReleaseTimestamp.jar" BACKUP_NAME="app-$releaseTimestamp.jar"
mkdir -p "`$APP_DIR/releases" "`$APP_DIR/backups" "`$APP_DIR/logs" mkdir -p "`$APP_DIR/releases" "`$APP_DIR/backups" "`$APP_DIR/logs"
test -f "`$RELEASE" test -f "`$RELEASE"
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "^`$SERVICE.service"; then if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "^`$SERVICE.service"; then
@@ -582,75 +535,20 @@ if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "
else else
if [ -f "`$APP_DIR/app.pid" ]; then kill "`$(cat "`$APP_DIR/app.pid")" >/dev/null 2>&1 || true; fi if [ -f "`$APP_DIR/app.pid" ]; then kill "`$(cat "`$APP_DIR/app.pid")" >/dev/null 2>&1 || true; fi
pkill -f "java .*`$APP_DIR/app.jar" >/dev/null 2>&1 || true pkill -f "java .*`$APP_DIR/app.jar" >/dev/null 2>&1 || true
nohup java -jar "`$APP_DIR/app.jar" > "`$APP_DIR/logs/app-$ReleaseTimestamp.log" 2>&1 & nohup java -jar "`$APP_DIR/app.jar" > "`$APP_DIR/logs/app-$releaseTimestamp.log" 2>&1 &
echo `$! > "`$APP_DIR/app.pid" echo `$! > "`$APP_DIR/app.pid"
fi fi
deadline=`$((`$(date +%s) + `$HEALTH_TIMEOUT)) deadline=`$((`$(date +%s) + `$HEALTH_TIMEOUT))
until curl -fsS "http://127.0.0.1:`$HEALTH_PORT`$HEALTH_PATH" >/tmp/yuminail-health.out 2>/tmp/yuminail-health.err; do until curl -fsS "http://127.0.0.1:`$HEALTH_PORT`$HEALTH_PATH" >/tmp/fingertip-designer-health.out 2>/tmp/fingertip-designer-health.err; do
if [ "`$(date +%s)" -ge "`$deadline" ]; then if [ "`$(date +%s)" -ge "`$deadline" ]; then
echo "Health check failed for `$SERVICE on port `$HEALTH_PORT" echo "Health check failed for `$SERVICE on port `$HEALTH_PORT"
cat /tmp/yuminail-health.err || true cat /tmp/fingertip-designer-health.err || true
if command -v systemctl >/dev/null 2>&1; then journalctl -u "`$SERVICE" -n 80 --no-pager || true; fi if command -v systemctl >/dev/null 2>&1; then journalctl -u "`$SERVICE" -n 80 --no-pager || true; fi
exit 43 exit 43
fi fi
sleep 3 sleep 3
done done
cat /tmp/yuminail-health.out cat /tmp/fingertip-designer-health.out
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "^`$SERVICE.service"; then
systemctl --no-pager --full status "`$SERVICE" | sed -n '1,30p'
else
ps -fp "`$(cat "`$APP_DIR/app.pid")"
fi
"@
}
function Get-BackendRollbackCommand {
param(
[string]$RemoteAppDir,
[string]$ServiceName,
[int]$HealthPort
)
$appDir = ConvertTo-BashSingleQuoted $RemoteAppDir
$service = ConvertTo-BashSingleQuoted $ServiceName
$healthPath = ConvertTo-BashSingleQuoted $HealthPath
$timeout = [string]$HealthTimeoutSeconds
$healthPortText = [string]$HealthPort
return @"
set -e
APP_DIR=$appDir
SERVICE=$service
HEALTH_PATH=$healthPath
HEALTH_PORT=$healthPortText
HEALTH_TIMEOUT=$timeout
BACKUP=`$(ls -1t "`$APP_DIR/backups"/app-*.jar 2>/dev/null | head -n 1 || true)
if [ -z "`$BACKUP" ]; then
echo "No backup jar found for rollback: `$APP_DIR"
exit 44
fi
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "^`$SERVICE.service"; then
systemctl stop "`$SERVICE" || true
fi
cp "`$BACKUP" "`$APP_DIR/app.jar"
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "^`$SERVICE.service"; then
systemctl start "`$SERVICE"
else
if [ -f "`$APP_DIR/app.pid" ]; then kill "`$(cat "`$APP_DIR/app.pid")" >/dev/null 2>&1 || true; fi
pkill -f "java .*`$APP_DIR/app.jar" >/dev/null 2>&1 || true
nohup java -jar "`$APP_DIR/app.jar" > "`$APP_DIR/logs/app-rollback-$ReleaseTimestamp.log" 2>&1 &
echo `$! > "`$APP_DIR/app.pid"
fi
deadline=`$((`$(date +%s) + `$HEALTH_TIMEOUT))
until curl -fsS "http://127.0.0.1:`$HEALTH_PORT`$HEALTH_PATH" >/tmp/yuminail-health.out 2>/tmp/yuminail-health.err; do
if [ "`$(date +%s)" -ge "`$deadline" ]; then
echo "Rollback health check failed for `$SERVICE"
cat /tmp/yuminail-health.err || true
exit 45
fi
sleep 3
done
echo "Rolled back `$SERVICE to `$BACKUP"
"@ "@
} }
@@ -665,26 +563,18 @@ function Publish-BackendGroup {
) )
$artifactBaseName = [System.IO.Path]::GetFileNameWithoutExtension($ArtifactPath) $artifactBaseName = [System.IO.Path]::GetFileNameWithoutExtension($ArtifactPath)
$releaseName = "$artifactBaseName-$ReleaseTimestamp.jar" $releaseName = "$artifactBaseName-$releaseTimestamp.jar"
$quotedRemoteAppDir = ConvertTo-BashSingleQuoted $RemoteAppDir $quotedRemoteAppDir = ConvertTo-BashSingleQuoted $RemoteAppDir
Write-Step "Prepare $GroupName on $($Servers.Count) hosts" Write-Step "准备 $GroupName 目标机器"
foreach ($server in $Servers) { foreach ($server in $Servers) {
Write-Host "$GroupName target: $($server.Name) $($server.User)@$($server.Host):$($server.Port)" Write-Host "$GroupName target: $($server.Name) $($server.User)@$($server.Host):$($server.Port)"
Invoke-RemoteShell $server "mkdir -p $quotedRemoteAppDir/releases $quotedRemoteAppDir/backups $quotedRemoteAppDir/logs" Invoke-RemoteShell $server "mkdir -p $quotedRemoteAppDir/releases $quotedRemoteAppDir/backups $quotedRemoteAppDir/logs"
Copy-FileToRemote $ArtifactPath $server "$RemoteAppDir/releases/$releaseName" Copy-FileToRemote $ArtifactPath $server "$RemoteAppDir/releases/$releaseName"
} }
Write-Step "Switch $GroupName release" Write-Step "切换 $GroupName 发布版本"
$deployCommand = Get-BackendDeployCommand $RemoteAppDir $ServiceName $releaseName $HealthPort $deployCommand = Get-BackendDeployCommand $RemoteAppDir $ServiceName $releaseName $HealthPort
$rollbackCommand = Get-BackendRollbackCommand $RemoteAppDir $ServiceName $HealthPort Invoke-RemoteShellMany $Servers $deployCommand $GroupName
try {
Invoke-RemoteShellParallel $Servers $deployCommand $GroupName
}
catch {
Write-Warning "$GroupName deployment failed. Running rollback on this group."
Invoke-RemoteShellParallel $Servers $rollbackCommand "$GroupName-rollback"
throw
}
} }
function Get-WebDeployCommand { function Get-WebDeployCommand {
@@ -696,7 +586,7 @@ function Get-WebDeployCommand {
set -e set -e
WEB_DIR=$webDir WEB_DIR=$webDir
ARCHIVE_NAME=$archiveName ARCHIVE_NAME=$archiveName
RELEASE_BASE="`$WEB_DIR/releases/$ReleaseTimestamp" RELEASE_BASE="`$WEB_DIR/releases/$releaseTimestamp"
ARCHIVE="`$WEB_DIR/releases/`$ARCHIVE_NAME" ARCHIVE="`$WEB_DIR/releases/`$ARCHIVE_NAME"
mkdir -p "`$RELEASE_BASE" mkdir -p "`$RELEASE_BASE"
if [ -L "`$WEB_DIR/current" ]; then readlink "`$WEB_DIR/current" > "`$WEB_DIR/previous-release.txt"; fi if [ -L "`$WEB_DIR/current" ]; then readlink "`$WEB_DIR/current" > "`$WEB_DIR/previous-release.txt"; fi
@@ -717,67 +607,33 @@ echo "Web current -> `$TARGET"
"@ "@
} }
function Get-WebRollbackCommand {
$webDir = ConvertTo-BashSingleQuoted $WebRemoteDir
return @"
set -e
WEB_DIR=$webDir
if [ ! -f "`$WEB_DIR/previous-release.txt" ]; then
echo "No previous web release recorded."
exit 46
fi
PREVIOUS=`$(cat "`$WEB_DIR/previous-release.txt")
if [ -z "`$PREVIOUS" ] || [ ! -d "`$PREVIOUS" ]; then
echo "Previous web release is invalid: `$PREVIOUS"
exit 47
fi
ln -sfn "`$PREVIOUS" "`$WEB_DIR/current"
nginx -t
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "^nginx.service"; then
systemctl reload nginx
else
nginx -s reload
fi
echo "Rolled back web current -> `$PREVIOUS"
"@
}
function Publish-Web { function Publish-Web {
param([object]$Server, [string]$ArchivePath) param([object]$Server, [string]$ArchivePath)
$archiveName = "yuminail-frontend-dist-$ReleaseTimestamp.tar.gz" $archiveName = "fingertip-designer-frontend-dist-$releaseTimestamp.tar.gz"
$quotedWebRemoteDir = ConvertTo-BashSingleQuoted $WebRemoteDir $quotedWebRemoteDir = ConvertTo-BashSingleQuoted $WebRemoteDir
Write-Step "Prepare Web on $($Server.Name)" Write-Step "准备 Web 目标机器"
Invoke-RemoteShell $Server "mkdir -p $quotedWebRemoteDir/releases" Invoke-RemoteShell $Server "mkdir -p $quotedWebRemoteDir/releases"
Copy-FileToRemote $ArchivePath $Server "$WebRemoteDir/releases/$archiveName" Copy-FileToRemote $ArchivePath $Server "$WebRemoteDir/releases/$archiveName"
Write-Step "Switch Web release" Write-Step "切换 Web 发布版本"
$deployCommand = Get-WebDeployCommand $archiveName Invoke-RemoteShell $Server (Get-WebDeployCommand $archiveName)
$rollbackCommand = Get-WebRollbackCommand
try {
Invoke-RemoteShell $Server $deployCommand
}
catch {
Write-Warning "Web deployment failed. Running web rollback."
Invoke-RemoteShell $Server $rollbackCommand
throw
}
} }
function Initialize-ProductionDatabase { function Initialize-ProductionDatabase {
param([object]$DatabaseServer, [string]$SqlArtifact) param([object]$DatabaseServer, [string]$SqlArtifact)
Test-SqlSafety $SqlArtifact Assert-InitSqlSafe $SqlArtifact
$dbUserValue = if ($DatabaseUser) { $DatabaseUser } else { $DatabaseServer.User } $dbUserValue = if ($DatabaseUser) { $DatabaseUser } else { $DatabaseServer.User }
$dbPasswordValue = if ($DatabasePassword) { $DatabasePassword } else { $DatabaseServer.Password } $dbPasswordValue = if ($DatabasePassword) { $DatabasePassword } else { $DatabaseServer.Password }
if (-not $dbUserValue) { if (-not $dbUserValue) {
throw "Database user is empty. Pass -DatabaseUser or provide it in the workbook row." throw "数据库用户名为空,请传入 -DatabaseUser 或在服务器清单中填写。"
} }
$remoteSqlPath = "/tmp/yuminail-init-$ReleaseTimestamp.sql" $remoteSqlPath = "/tmp/fingertip-designer-init-$releaseTimestamp.sql"
Write-Step "Initialize empty production database" Write-Step "初始化生产空库"
Write-Host "Database target: $($DatabaseServer.Name) $($DatabaseServer.Host):$DatabasePort/$DatabaseName" Write-Host "数据库目标:$($DatabaseServer.Name) $($DatabaseServer.Host):$DatabasePort/$DatabaseName"
Invoke-RemoteShell $DatabaseServer "rm -f '$remoteSqlPath'" Invoke-RemoteShell $DatabaseServer "rm -f '$remoteSqlPath'"
Copy-FileToRemote $SqlArtifact $DatabaseServer $remoteSqlPath -Sensitive Copy-FileToRemote $SqlArtifact $DatabaseServer $remoteSqlPath -Sensitive
@@ -825,12 +681,13 @@ function Write-ReleaseManifest {
[object[]]$CoreServers, [object[]]$CoreServers,
[object[]]$GatewayServers, [object[]]$GatewayServers,
[object]$WebServer, [object]$WebServer,
[object]$DatabaseServer [object]$DatabaseServer,
[string]$ResolvedServerInfoPath
) )
$manifest = [pscustomobject]@{ $manifest = [pscustomobject]@{
releaseTimestamp = $ReleaseTimestamp releaseTimestamp = $releaseTimestamp
repoRoot = $ResolvedRepoRoot repoRoot = $resolvedRepoRoot
git = $Package.Git git = $Package.Git
artifacts = $Package.Hashes artifacts = $Package.Hashes
targets = [pscustomobject]@{ targets = [pscustomobject]@{
@@ -842,36 +699,38 @@ function Write-ReleaseManifest {
parameters = [pscustomobject]@{ parameters = [pscustomobject]@{
initializeDatabase = -not [bool]$SkipDatabaseInit initializeDatabase = -not [bool]$SkipDatabaseInit
databaseName = $DatabaseName databaseName = $DatabaseName
serverInfoPath = $resolvedServerInfoPath serverInfoPath = $ResolvedServerInfoPath
coreRemoteAppDir = $CoreRemoteAppDir coreRemoteAppDir = $CoreRemoteAppDir
gatewayRemoteAppDir = $GatewayRemoteAppDir gatewayRemoteAppDir = $GatewayRemoteAppDir
webRemoteDir = $WebRemoteDir webRemoteDir = $WebRemoteDir
publicBaseUrl = $PublicBaseUrl publicBaseUrl = $PublicBaseUrl
managerMiniProgramApi = "$PublicBaseUrl/api/admin"
nacosNamespace = "FingertipDesigner"
dryRun = [bool]$DryRun dryRun = [bool]$DryRun
deploy = [bool]$Deploy deploy = [bool]$Deploy
} }
} }
$manifest | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $ManifestPath -Encoding UTF8 $manifest | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $manifestPath -Encoding UTF8
Write-Host "Manifest: $ManifestPath" Write-Host "Manifest: $manifestPath"
} }
function Invoke-PublicSmokeTests { function Invoke-PublicSmokeTests {
if ($DryRun) { if ($DryRun) {
Write-Host "DryRun public smoke tests:" Write-Host "DryRun public smoke tests:"
Write-Host "GET $PublicBaseUrl" Write-Host "GET $PublicBaseUrl/health/check"
Write-Host "GET $PublicBaseUrl/api/shop/list" Write-Host "GET $PublicBaseUrl/api/shop/list"
return return
} }
Write-Step "Public smoke tests" Write-Step "生产公开冒烟"
foreach ($url in @($PublicBaseUrl, "$PublicBaseUrl/api/shop/list")) { foreach ($url in @("$PublicBaseUrl/health/check", "$PublicBaseUrl/api/shop/list")) {
Write-Host "GET $url" Write-Host "GET $url"
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 20 $response = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 20
Write-Host "Status $($response.StatusCode) Length $($response.RawContentLength)" Write-Host "Status $($response.StatusCode) Length $($response.RawContentLength)"
} }
} }
Write-Step "Read server workbook" Write-Step "读取服务器清单"
$resolvedServerInfoPath = Resolve-ServerInfoPath $ServerInfoPath $resolvedServerInfoPath = Resolve-ServerInfoPath $ServerInfoPath
$servers = @(Get-ServersFromWorkbook $resolvedServerInfoPath) $servers = @(Get-ServersFromWorkbook $resolvedServerInfoPath)
$coreServers = @($servers | Where-Object { $_.Name -match $CorePattern }) $coreServers = @($servers | Where-Object { $_.Name -match $CorePattern })
@@ -885,39 +744,38 @@ else {
$databaseServers = @($servers | Where-Object { $_.Name -eq $DatabaseTargetName }) $databaseServers = @($servers | Where-Object { $_.Name -eq $DatabaseTargetName })
if ($coreServers.Count -eq 0) { if ($coreServers.Count -eq 0) {
throw "No Core servers matched pattern: $CorePattern" throw "没有匹配到 Core 服务器,匹配规则:$CorePattern"
} }
if ($gatewayServers.Count -eq 0) { if ($gatewayServers.Count -eq 0) {
throw "No Gateway servers matched pattern: $GatewayPattern" throw "没有匹配到 Gateway 服务器,匹配规则:$GatewayPattern"
} }
if ($webServers.Count -ne 1) { if ($webServers.Count -ne 1) {
$webSelector = if ($WebTargetName) { "name '$WebTargetName'" } else { "host '$WebTargetHost'" } $webSelector = if ($WebTargetName) { "名称 $WebTargetName" } else { "主机 $WebTargetHost" }
throw "Expected exactly one Web target by $webSelector, found $($webServers.Count)." throw "Web 目标必须唯一,当前按 $webSelector 找到 $($webServers.Count) 个。"
} }
if ((-not $SkipDatabaseInit) -and $databaseServers.Count -ne 1) { if ((-not $SkipDatabaseInit) -and $databaseServers.Count -ne 1) {
throw "Expected exactly one database target named '$DatabaseTargetName', found $($databaseServers.Count)." throw "数据库初始化目标必须唯一,当前按 $DatabaseTargetName 找到 $($databaseServers.Count) 个。"
} }
Assert-ProductionTarget (@($coreServers) + @($gatewayServers) + @($webServers)) Assert-ProductionTarget (@($coreServers) + @($gatewayServers) + @($webServers))
$databaseServer = if (-not $SkipDatabaseInit) { $databaseServers[0] } else { $null } $databaseServer = if (-not $SkipDatabaseInit) { $databaseServers[0] } else { $null }
Write-Host "Server workbook: $resolvedServerInfoPath" Write-Host "服务器清单:$resolvedServerInfoPath"
Write-Host "Selected YumiNail targets:"
@($coreServers + $gatewayServers + $webServers) | Select-Object Name, Host, Port, User, Purpose, Environment | Format-Table -AutoSize @($coreServers + $gatewayServers + $webServers) | Select-Object Name, Host, Port, User, Purpose, Environment | Format-Table -AutoSize
if ($databaseServer) { if ($databaseServer) {
Write-Host "Database init target:" Write-Host "数据库初始化目标:"
$databaseServer | Select-Object Name, Host, Port, User, Purpose, Environment | Format-Table -AutoSize $databaseServer | Select-Object Name, Host, Port, User, Purpose, Environment | Format-Table -AutoSize
} }
Write-Step "Check git state" Write-Step "检查工作区"
$gitState = Test-GitState $gitState = Test-GitState
Write-Step "Build release package" Write-Step "构建发布包"
$package = Build-ReleasePackage $gitState $package = Build-ReleasePackage $gitState
Write-ReleaseManifest $package $coreServers $gatewayServers $webServers[0] $databaseServer Write-ReleaseManifest $package $coreServers $gatewayServers $webServers[0] $databaseServer $resolvedServerInfoPath
if (-not $Deploy) { if (-not $Deploy) {
Write-Host "Package prepared. Add -Deploy to publish. Add -DryRun to print remote actions without changing production." Write-Host "发布包已生成。传入 -Deploy 才会发布到生产;传入 -DryRun 可打印远程动作但不修改远端。"
exit 0 exit 0
} }
@@ -925,7 +783,7 @@ if (-not $SkipDatabaseInit) {
Initialize-ProductionDatabase $databaseServer $package.InitSql Initialize-ProductionDatabase $databaseServer $package.InitSql
} }
else { else {
Write-Host "Database initialization skipped." Write-Host "已跳过数据库初始化。"
} }
Publish-BackendGroup "Core" $coreServers $package.CoreJar $CoreRemoteAppDir $CoreServiceName $CoreHealthPort Publish-BackendGroup "Core" $coreServers $package.CoreJar $CoreRemoteAppDir $CoreServiceName $CoreHealthPort
@@ -934,4 +792,4 @@ Publish-Web $webServers[0] $package.FrontendArchive
Invoke-PublicSmokeTests Invoke-PublicSmokeTests
Write-Host "" Write-Host ""
Write-Host "YumiNail production deployment workflow finished." Write-Host "FingertipDesigner 生产发布流程完成。"
+77 -47
View File
@@ -12,12 +12,13 @@ $releaseDir = Join-Path $releaseRoot $timestamp
$backendDir = Join-Path $releaseDir "backend" $backendDir = Join-Path $releaseDir "backend"
$frontendDir = Join-Path $releaseDir "frontend" $frontendDir = Join-Path $releaseDir "frontend"
$miniProgramDir = Join-Path $releaseDir "miniprograms" $miniProgramDir = Join-Path $releaseDir "miniprograms"
$sqlPath = Join-Path $repoRoot "scripts\sql\init\YumiNail.sql"
function Resolve-Maven { function Resolve-Maven {
param([string]$PreferredPath) param([string]$PreferredPath)
if ($PreferredPath -and (Test-Path $PreferredPath)) { if ($PreferredPath -and (Test-Path -LiteralPath $PreferredPath)) {
return $PreferredPath return (Resolve-Path -LiteralPath $PreferredPath).Path
} }
$fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue $fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue
@@ -25,22 +26,33 @@ function Resolve-Maven {
return $fromPath.Source return $fromPath.Source
} }
$fallback = "D:\开发\apache-maven-3.9.9\bin\mvn.cmd" $fromPath = Get-Command mvn -ErrorAction SilentlyContinue
if (Test-Path $fallback) { if ($fromPath) {
return $fallback return $fromPath.Source
} }
throw "Cannot find mvn.cmd. Pass -MavenPath with an absolute Maven path." throw "找不到 Maven,请通过 -MavenPath 传入 Maven 可执行文件绝对路径。"
} }
function Invoke-Step { function Invoke-Native {
param( param(
[string]$Name, [string]$FilePath,
[scriptblock]$Script [string[]]$Arguments,
[string]$WorkingDirectory
) )
Write-Host "==> $Name" Write-Host ">> $FilePath $($Arguments -join ' ')"
& $Script $previousLocation = Get-Location
try {
Set-Location -LiteralPath $WorkingDirectory
& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "命令执行失败,退出码 ${LASTEXITCODE}:$FilePath"
}
}
finally {
Set-Location $previousLocation
}
} }
function Copy-Directory { function Copy-Directory {
@@ -49,12 +61,32 @@ function Copy-Directory {
[string]$Destination [string]$Destination
) )
if (!(Test-Path $Source)) { if (-not (Test-Path -LiteralPath $Source)) {
throw "Missing source directory: $Source" throw "缺少待打包目录:$Source"
} }
New-Item -ItemType Directory -Force -Path $Destination | Out-Null New-Item -ItemType Directory -Force -Path $Destination | Out-Null
Copy-Item -Path (Join-Path $Source "*") -Destination $Destination -Recurse -Force Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
}
function Copy-RequiredFile {
param(
[string]$Source,
[string]$Destination
)
if (-not (Test-Path -LiteralPath $Source)) {
throw "缺少待打包文件:$Source"
}
Copy-Item -LiteralPath $Source -Destination $Destination -Force
}
function Write-Step {
param([string]$Message)
Write-Host ""
Write-Host "==> $Message"
} }
$maven = Resolve-Maven $MavenPath $maven = Resolve-Maven $MavenPath
@@ -65,52 +97,50 @@ if ($SkipTests) {
$mavenArgs += "-DskipTests" $mavenArgs += "-DskipTests"
} }
Invoke-Step "Build YumiNail-Core" { Write-Step "构建 FD-Core"
Push-Location (Join-Path $repoRoot "YumiNail-Core") Invoke-Native $maven $mavenArgs (Join-Path $repoRoot "FD-Core")
try { & $maven @mavenArgs } finally { Pop-Location }
}
Invoke-Step "Build YumiNail-Gateway" { Write-Step "构建 FD-Gateway"
Push-Location (Join-Path $repoRoot "YumiNail-Gateway") Invoke-Native $maven $mavenArgs (Join-Path $repoRoot "FD-Gateway")
try { & $maven @mavenArgs } finally { Pop-Location }
}
Invoke-Step "Build YumiNail-Frontend" { Write-Step "构建 FD-Frontend"
Push-Location (Join-Path $repoRoot "YumiNail-Frontend") $frontendRoot = Join-Path $repoRoot "FD-Frontend"
try { if (-not (Test-Path -LiteralPath (Join-Path $frontendRoot "node_modules"))) {
if (!(Test-Path "node_modules")) { Invoke-Native "npm" @("ci") $frontendRoot
npm ci
}
npm run build
} finally {
Pop-Location
}
} }
Invoke-Native "npm" @("run", "build") $frontendRoot
Copy-Item (Join-Path $repoRoot "YumiNail-Core\target\YumiNail-Core.jar") (Join-Path $backendDir "YumiNail-Core.jar") -Force $coreJar = Join-Path $repoRoot "FD-Core\target\FingertipDesigner-Core.jar"
Copy-Item (Join-Path $repoRoot "YumiNail-Gateway\target\YumiNail-Gateway.jar") (Join-Path $backendDir "YumiNail-Gateway.jar") -Force $gatewayJar = Join-Path $repoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
Copy-Directory (Join-Path $repoRoot "YumiNail-Frontend\dist") (Join-Path $frontendDir "dist") $frontendDist = Join-Path $frontendRoot "dist"
Copy-Directory (Join-Path $repoRoot "WeChatProgram") (Join-Path $miniProgramDir "WeChatProgram")
Copy-Directory (Join-Path $repoRoot "YumiNail-Admin-Program") (Join-Path $miniProgramDir "YumiNail-Admin-Program") Copy-RequiredFile $coreJar (Join-Path $backendDir "FingertipDesigner-Core.jar")
Copy-Item (Join-Path $repoRoot "YumiNail-Core\src\main\resources\files\YumiNail.sql") (Join-Path $releaseDir "YumiNail.sql") -Force Copy-RequiredFile $gatewayJar (Join-Path $backendDir "FingertipDesigner-Gateway.jar")
Copy-Directory $frontendDist (Join-Path $frontendDir "dist")
Copy-Directory (Join-Path $repoRoot "FD-WeChat-Fronted") (Join-Path $miniProgramDir "FD-WeChat-Fronted")
Copy-Directory (Join-Path $repoRoot "FM-Wechat-Fronted") (Join-Path $miniProgramDir "FM-Wechat-Fronted")
Copy-RequiredFile $sqlPath (Join-Path $releaseDir "YumiNail.sql")
$manifest = @( $manifest = @(
"# YumiNail Release $timestamp", "# FingertipDesigner Release $timestamp",
"", "",
"- backend/YumiNail-Core.jar", "- backend/FingertipDesigner-Core.jar",
"- backend/YumiNail-Gateway.jar", "- backend/FingertipDesigner-Gateway.jar",
"- frontend/dist", "- frontend/dist",
"- miniprograms/WeChatProgram", "- miniprograms/FD-WeChat-Fronted",
"- miniprograms/YumiNail-Admin-Program", "- miniprograms/FM-Wechat-Fronted",
"- YumiNail.sql", "- YumiNail.sql",
"", "",
"Nacos namespace: YumiNail-Dev", "Nacos namespace: FingertipDesigner",
"Database initialized by: YumiNail.sql" "Database initialized by: scripts/sql/init/YumiNail.sql",
"Database name: FingertipDesigner",
"Manager mini program API: https://yunail.art/api/admin"
) )
$manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md") $manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md")
$zipPath = "$releaseDir.zip" $zipPath = "$releaseDir.zip"
Compress-Archive -Path (Join-Path $releaseDir "*") -DestinationPath $zipPath -Force Compress-Archive -Path (Join-Path $releaseDir "*") -DestinationPath $zipPath -Force
Write-Host "Release folder: $releaseDir" Write-Host ""
Write-Host "Release archive: $zipPath" Write-Host "发布目录:$releaseDir"
Write-Host "发布压缩包:$zipPath"
+91 -46
View File
@@ -3,10 +3,10 @@
-- 1. 首次部署空库时,只需要执行本文件即可完成基础建表、结构补丁、权限种子、基础参数、协议、MessageHub、VIP 规则与管理员初始化。 -- 1. 首次部署空库时,只需要执行本文件即可完成基础建表、结构补丁、权限种子、基础参数、协议、MessageHub、VIP 规则与管理员初始化。
-- 2. 2026-03-20_user_asset_vip_coupon_permission_patch.sql、2026-03-25_user_shop_binding_and_shop_status_patch.sql、 -- 2. 2026-03-20_user_asset_vip_coupon_permission_patch.sql、2026-03-25_user_shop_binding_and_shop_status_patch.sql、
-- 2026-03-20_init_admin_permission_template.sql 仍保留用于已有数据库的增量升级,不再作为空库首选入口。 -- 2026-03-20_init_admin_permission_template.sql 仍保留用于已有数据库的增量升级,不再作为空库首选入口。
-- 3. 当前 Nacos datasource.yaml 指向 nailart,本文件默认按该库名初始化;如果你的实际数据库名不同,请先统一 datasource 与下方库名。 -- 3. 当前 Nacos datasource.yaml 必须指向 FingertipDesigner,本文件默认按该库名初始化;Linux MySQL 环境下库名大小写敏感,请先统一 datasource 与下方库名。
-- 4. 本文件只初始化一个平台管理员 xiaowang(默认密码 888888),不写入开发/验收用户、门店、作品、标签、订单、消息公告等业务数据。 -- 4. 本文件只初始化一个平台管理员 xiaowang(默认密码 888888),不写入开发/验收用户、门店、作品、标签、订单、消息公告等业务数据。
CREATE DATABASE IF NOT EXISTS nailart DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE DATABASE IF NOT EXISTS FingertipDesigner DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use nailart; use FingertipDesigner;
-- auto-generated definition -- auto-generated definition
create table t_balance create table t_balance
@@ -272,36 +272,38 @@ create index idx_t_nail_artist_info_participate
-- auto-generated definition -- auto-generated definition
create table t_object_storage_file create table t_object_storage_file
( (
id bigint unsigned auto_increment comment '文件记录唯一主键ID(雪花ID)' id bigint unsigned auto_increment comment '????ID'
primary key comment '对象存储文件主键索引', primary key comment '????????',
file_name varchar(100) not null comment '文件名称', file_name varchar(100) not null comment '????',
file_url text not null comment '文件访问链接', file_url text not null comment '??????',
object_name varchar(512) null comment '对象存储Key', object_name varchar(512) null comment '????Key',
minio_url text null comment 'MinIO访问链接', primary_provider varchar(64) null comment '??????',
oss_url text null comment '阿里云OSS内部备份链接', primary_url text null comment '???????',
content_type varchar(128) null comment '文件Content-Type', backup_provider varchar(64) null comment '???????',
file_size bigint unsigned null comment '文件大小,单位字节', backup_url text null comment '????????',
minio_upload_status tinyint unsigned default 0 not null comment 'MinIO上传状态:0-PENDING,1-SUCCEEDED,2-FAILED', content_type varchar(128) null comment '??Content-Type',
oss_upload_status tinyint unsigned default 0 not null comment 'OSS上传状态:0-PENDING,1-SUCCEEDED,2-FAILED', file_size bigint unsigned null comment '?????????',
oss_retry_count int unsigned default 0 not null comment 'OSS备份重试次数', primary_upload_status tinyint unsigned default 0 not null comment '????????0????1???2??',
oss_last_error varchar(500) null comment '最近一次OSS备份失败原因', backup_upload_status tinyint unsigned default 0 not null comment '?????????0????1???2??',
oss_uploaded_at datetime null comment 'OSS备份成功时间', backup_retry_count int unsigned default 0 not null comment '??????',
oss_last_retry_time datetime null comment '最近一次OSS备份重试时间', backup_last_error varchar(500) null comment '??????????',
create_time datetime default CURRENT_TIMESTAMP not null comment '文件上传时间', backup_uploaded_at datetime null comment '??????',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '文件更新时间', backup_last_retry_time datetime null comment '??????????',
status tinyint unsigned default 1 null comment '文件状态:1-可用,0-不可用,2-回收站', create_time datetime default CURRENT_TIMESTAMP not null comment '??????',
delete_time datetime null comment '文件删除时间(NULL表示未删除)', update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '??????',
recycle_time datetime null comment '文件移入回收站时间(NULL表示未移入)' status tinyint unsigned default 1 null comment '?????1???0????2???',
delete_time datetime null comment '??????',
recycle_time datetime null comment '?????????'
) )
comment '对象存储文件信息表'; comment '?????????';
create index idx_status create index idx_status
on t_object_storage_file (status) on t_object_storage_file (status)
comment '按文件状态查询的索引'; comment '??????';
create index idx_object_storage_file_oss_retry create index idx_object_storage_file_backup_retry
on t_object_storage_file (oss_upload_status, minio_upload_status, status) on t_object_storage_file (backup_upload_status, primary_upload_status, status)
comment 'OSS备份失败重试扫描索引'; comment '????????';
-- auto-generated definition -- auto-generated definition
create table t_order create table t_order
@@ -568,6 +570,10 @@ create table t_user
nickname varchar(50) not null comment '用户昵称', nickname varchar(50) not null comment '用户昵称',
account varchar(50) not null comment '用户账号(登录用)', account varchar(50) not null comment '用户账号(登录用)',
phone varchar(50) null comment '手机号', phone varchar(50) null comment '手机号',
contact_phone varchar(50) null comment '联系电话',
birthday date null comment '生日',
wechat_id varchar(100) null comment '微信号',
wechat_qr_code varchar(512) null comment '微信二维码',
email varchar(100) null comment '邮箱', email varchar(100) null comment '邮箱',
phone_verified tinyint unsigned default 0 null comment '手机号是否已验证:0-未验证,1-已验证', phone_verified tinyint unsigned default 0 null comment '手机号是否已验证:0-未验证,1-已验证',
email_verified tinyint unsigned default 0 null comment '邮箱是否已验证:0-未验证,1-已验证', email_verified tinyint unsigned default 0 null comment '邮箱是否已验证:0-未验证,1-已验证',
@@ -935,25 +941,28 @@ CALL sp_add_column_if_not_exists('t_balance', 'total_recharge_amount', 'decimal(
CALL sp_add_column_if_not_exists('t_balance', 'last_recharge_time', 'datetime NULL COMMENT ''最近一次充值时间'''); CALL sp_add_column_if_not_exists('t_balance', 'last_recharge_time', 'datetime NULL COMMENT ''最近一次充值时间''');
CALL sp_add_column_if_not_exists('t_balance', 'update_time', 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ''更新时间'''); CALL sp_add_column_if_not_exists('t_balance', 'update_time', 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ''更新时间''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'object_name', 'varchar(512) NULL COMMENT ''对象存储Key'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'object_name', 'varchar(512) NULL COMMENT ''????Key''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'minio_url', 'text NULL COMMENT ''MinIO访问链接'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'primary_provider', 'varchar(64) NULL COMMENT ''??????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_url', 'text NULL COMMENT ''阿里云OSS内部备份链接'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'primary_url', 'text NULL COMMENT ''???????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'content_type', 'varchar(128) NULL COMMENT ''文件Content-Type'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_provider', 'varchar(64) NULL COMMENT ''???????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'file_size', 'bigint unsigned NULL COMMENT ''文件大小,单位字节'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_url', 'text NULL COMMENT ''????????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'minio_upload_status', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''MinIO上传状态:0-PENDING,1-SUCCEEDED,2-FAILED'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'content_type', 'varchar(128) NULL COMMENT ''??Content-Type''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_upload_status', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''OSS上传状态:0-PENDING,1-SUCCEEDED,2-FAILED'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'file_size', 'bigint unsigned NULL COMMENT ''?????????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_retry_count', 'int unsigned NOT NULL DEFAULT 0 COMMENT ''OSS备份重试次数'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'primary_upload_status', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''????????0????1???2??''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_last_error', 'varchar(500) NULL COMMENT ''最近一次OSS备份失败原因'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_upload_status', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''?????????0????1???2??''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_uploaded_at', 'datetime NULL COMMENT ''OSS备份成功时间'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_retry_count', 'int unsigned NOT NULL DEFAULT 0 COMMENT ''??????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'oss_last_retry_time', 'datetime NULL COMMENT ''最近一次OSS备份重试时间'''); CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_last_error', 'varchar(500) NULL COMMENT ''??????????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_uploaded_at', 'datetime NULL COMMENT ''??????''');
CALL sp_add_column_if_not_exists('t_object_storage_file', 'backup_last_retry_time', 'datetime NULL COMMENT ''??????????''');
UPDATE t_object_storage_file UPDATE t_object_storage_file
SET minio_url = COALESCE(minio_url, file_url), SET primary_provider = COALESCE(primary_provider, 'QINIU_KODO'),
minio_upload_status = CASE WHEN minio_upload_status IS NULL OR minio_upload_status = 0 THEN 1 ELSE minio_upload_status END, primary_url = COALESCE(primary_url, file_url),
oss_upload_status = COALESCE(oss_upload_status, 0), backup_provider = COALESCE(backup_provider, 'ALIYUN_OSS'),
oss_retry_count = COALESCE(oss_retry_count, 0) primary_upload_status = CASE WHEN primary_upload_status IS NULL OR primary_upload_status = 0 THEN 1 ELSE primary_upload_status END,
backup_upload_status = COALESCE(backup_upload_status, 0),
backup_retry_count = COALESCE(backup_retry_count, 0)
WHERE status = 1; WHERE status = 1;
CALL sp_add_index_if_not_exists('t_object_storage_file', 'idx_object_storage_file_oss_retry', '(`oss_upload_status`, `minio_upload_status`, `status`)'); CALL sp_add_index_if_not_exists('t_object_storage_file', 'idx_object_storage_file_backup_retry', '(`backup_upload_status`, `primary_upload_status`, `status`)');
UPDATE t_balance UPDATE t_balance
SET total_recharge_amount = COALESCE(total_recharge_amount, 0.00) SET total_recharge_amount = COALESCE(total_recharge_amount, 0.00)
WHERE total_recharge_amount IS NULL; WHERE total_recharge_amount IS NULL;
@@ -968,6 +977,11 @@ CALL sp_add_column_if_not_exists('t_balance_change_detail', 'operator_id', 'bigi
CALL sp_add_column_if_not_exists('t_balance_change_detail', 'remark', 'varchar(255) NULL COMMENT ''备注'''); CALL sp_add_column_if_not_exists('t_balance_change_detail', 'remark', 'varchar(255) NULL COMMENT ''备注''');
CALL sp_add_column_if_not_exists('t_login_identity', 'create_time', 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''创建时间'''); CALL sp_add_column_if_not_exists('t_login_identity', 'create_time', 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''创建时间''');
CALL sp_add_column_if_not_exists('t_user', 'contact_phone', 'varchar(50) NULL COMMENT ''联系电话''');
CALL sp_add_column_if_not_exists('t_user', 'birthday', 'date NULL COMMENT ''生日''');
CALL sp_add_column_if_not_exists('t_user', 'wechat_id', 'varchar(100) NULL COMMENT ''微信号''');
CALL sp_add_column_if_not_exists('t_user', 'wechat_qr_code', 'varchar(512) NULL COMMENT ''微信二维码''');
UPDATE t_balance_change_detail UPDATE t_balance_change_detail
SET before_balance = COALESCE(before_balance, current_balance - amount), SET before_balance = COALESCE(before_balance, current_balance - amount),
after_balance = COALESCE(after_balance, current_balance), after_balance = COALESCE(after_balance, current_balance),
@@ -1712,6 +1726,36 @@ ON DUPLICATE KEY UPDATE
is_delete = 0, is_delete = 0,
update_time = NOW(); update_time = NOW();
CALL sp_add_column_if_not_exists('t_order', 'customer_remark', 'varchar(500) NULL COMMENT ''用户询价预约备注''');
CALL sp_add_column_if_not_exists('t_order', 'quote_status', 'varchar(32) NULL COMMENT ''报价状态:CONFIRMING/CONFIRMED/EXPIRED''');
CALL sp_add_column_if_not_exists('t_order', 'quote_user_confirmed', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''用户是否确认当前报价''');
CALL sp_add_column_if_not_exists('t_order', 'quote_shop_confirmed', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''店长是否确认当前报价''');
CALL sp_add_column_if_not_exists('t_order', 'quote_expire_time', 'datetime NULL COMMENT ''询价报价过期时间''');
CALL sp_add_column_if_not_exists('t_order', 'quote_confirmed_time', 'datetime NULL COMMENT ''双方确认报价时间''');
CALL sp_add_index_if_not_exists('t_order', 'idx_t_order_quote_status_expire', '(`quote_status`, `quote_expire_time`)');
CALL sp_add_column_if_not_exists('t_order_item', 'reference_price', 'decimal(10,2) NULL COMMENT ''作品参考价快照''');
CALL sp_add_column_if_not_exists('t_order_item', 'quoted_price', 'decimal(10,2) NULL COMMENT ''当前报价''');
CALL sp_add_column_if_not_exists('t_order_item', 'confirmed_price', 'decimal(10,2) NULL COMMENT ''最终确认价''');
CREATE TABLE IF NOT EXISTS t_order_quote_message
(
id bigint unsigned auto_increment comment '报价交互消息主键'
primary key,
order_id bigint unsigned not null comment '订单ID',
actor_id bigint unsigned null comment '操作人ID',
actor_type varchar(32) not null comment '操作人类型:USER/SHOP/SYSTEM',
action varchar(32) not null comment '动作:CREATE/SHOP_QUOTE/USER_REPLY/USER_CONFIRM/SHOP_CONFIRM/SYSTEM_CONFIRM/SYSTEM_EXPIRE',
remark varchar(500) null comment '备注',
items_snapshot text null comment '订单项报价快照JSON',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删'
)
comment '订单询价报价交互消息表';
CALL sp_add_index_if_not_exists('t_order_quote_message', 'idx_order_quote_message_order_id', '(`order_id`, `is_delete`, `create_time`)');
CREATE TABLE IF NOT EXISTS `t_messagehub_push_config` ( CREATE TABLE IF NOT EXISTS `t_messagehub_push_config` (
`id` bigint unsigned NOT NULL COMMENT '主键ID', `id` bigint unsigned NOT NULL COMMENT '主键ID',
`scene_code` varchar(80) NOT NULL COMMENT '业务场景编码', `scene_code` varchar(80) NOT NULL COMMENT '业务场景编码',
@@ -2422,7 +2466,8 @@ VALUES
(313931273555139000, 'MAP', 'MAP_PROVIDER', '当前地图渠道', 'TENCENT', 1, 'TENCENT 或 AMAP;决定后台店铺选点默认使用哪个地图渠道', NOW(), NOW(), 0), (313931273555139000, 'MAP', 'MAP_PROVIDER', '当前地图渠道', 'TENCENT', 1, 'TENCENT 或 AMAP;决定后台店铺选点默认使用哪个地图渠道', NOW(), NOW(), 0),
(313931273555139001, 'MAP', 'TENCENT_MAP_KEY', '腾讯 Web Key', '', 0, '用于后台腾讯地图选点和 Web 展示;请在后台参数管理中填入真实 Key 后启用', NOW(), NOW(), 0), (313931273555139001, 'MAP', 'TENCENT_MAP_KEY', '腾讯 Web Key', '', 0, '用于后台腾讯地图选点和 Web 展示;请在后台参数管理中填入真实 Key 后启用', NOW(), NOW(), 0),
(313931273555139002, 'MAP', 'AMAP_WEB_KEY', '高德 Web Key', '', 0, '用于后台高德地图选点和 Web 展示;Web 端 Key 与小程序 Key 分开维护', NOW(), NOW(), 0), (313931273555139002, 'MAP', 'AMAP_WEB_KEY', '高德 Web Key', '', 0, '用于后台高德地图选点和 Web 展示;Web 端 Key 与小程序 Key 分开维护', NOW(), NOW(), 0),
(313931273555139003, 'MAP', 'AMAP_MINI_KEY', '高德小程序 Key', '', 0, '用于后续小程序端高德 SDK/API 调用;不要与 Web Key 混用', NOW(), NOW(), 0) (313931273555139003, 'MAP', 'AMAP_MINI_KEY', '高德小程序 Key', '', 0, '用于后续小程序端高德 SDK/API 调用;不要与 Web Key 混用', NOW(), NOW(), 0),
(313931273555139004, 'USER', 'DEFAULT_PASSWORD', '后台新增用户默认密码', 'Fingertip@123', 1, '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
config_name = VALUES(config_name), config_name = VALUES(config_name),
remark = VALUES(remark), remark = VALUES(remark),
@@ -0,0 +1,32 @@
# 指尖管理师上线配置说明
## 生产配置约定
- 生产域名:`https://yunail.art`。
- 指尖管理师小程序管理端 API:`https://yunail.art/api/admin`。
- 网关对外管理端入口:`/api/admin/**`。
- Core 内部管理端入口:`/admin/**`。
- 生产数据库名:`FingertipDesigner`,Linux MySQL 环境下必须保持大小写一致。
- 生产 Nacos namespace:`FingertipDesigner`。
## Nacos 必填配置
生产 namespace 下必须存在以下配置文件:
- `core.yaml`
- `gateway.yaml`
- `infra.yaml`
- `secret.yaml`
- `logging.yaml`
`infra.yaml` 至少需要确认 MySQL、Redis、RabbitMQ、MyBatis-Plus 相关配置。`secret.yaml` 至少需要确认 MySQL 密码、Redis 密码、RabbitMQ 密码、JWT 密钥、微信小程序配置、七牛 Kodo 密钥。对象存储使用七牛 Kodo 作为主存储时,必须填写 `QINIU_KODO_ACCESS_KEY`、`QINIU_KODO_SECRET_KEY`、`QINIU_KODO_BUCKET_NAME`、`QINIU_KODO_DOMAIN`、`QINIU_KODO_ZONE`。
如启用阿里云 OSS 作为备份存储,必须同时启用 `ALIYUN_OSS_ENABLED=true` 并填写 endpoint、region、bucket、access key。若暂不使用备份存储,发布前需要确认对象存储备份队列和定时补偿不会影响主链路。
## 发布前确认项
- 微信后台已配置 `https://yunail.art` 为合法请求域名。
- 指尖管理师小程序与用户端小程序是否共用 appid 已经过产品/发布负责人确认。
- Core 与 Gateway 的生产端口和健康检查地址已与 systemd、Nginx、部署脚本保持一致。
- 上传大小限制已确认:当前 Servlet 单文件限制为 5MB,单请求限制为 10MB。
- 初始化 SQL 仅用于空库首次部署;已有生产库必须使用版本变更 SQL,不允许直接执行初始化 SQL 覆盖升级。