feat usn 类型改成int64

This commit is contained in:
2026-01-30 14:48:38 +08:00
parent 7eae358996
commit 30864dbc40
29 changed files with 3032 additions and 854 deletions

View File

@@ -10,11 +10,11 @@ param(
Get-ChildItem ./${dbName}/model/*.gen.go | ForEach-Object {
$c = Get-Content $_.FullName -Raw -Encoding UTF8
if ($c -match '\bSn\s+string\b' -and $c -notmatch 'BeforeCreate') {
if ($c -match '\bSn\s+int64\b' -and $c -notmatch 'BeforeCreate') {
$c -match 'type\s+(\w+)\s+struct' | Out-Null
$n = $matches[1]
$c = $c -replace '(?s)(import\s*\([^)]*)', "`$1`t`"git.hlsq.asia/mmorpg/service-common/utils`"`n"
$hook = "`n`n// Auto sn`nfunc (m *$n) BeforeCreate(_ *gorm.DB) error {`n`tif m.Sn == `"`" {`n`t`tm.Sn = utils.SnowflakeInstance().Generate().String()`n`t}`n`treturn nil`n}"
$hook = "`n`n// Auto sn`nfunc (m *$n) BeforeCreate(_ *gorm.DB) error {`n`tif m.Sn == 0 {`n`t`tm.Sn = utils.SnowflakeInstance().Generate().Int64()`n`t}`n`treturn nil`n}"
Set-Content $_.FullName ($c.TrimEnd() + $hook) -Encoding UTF8
}
}