fix(auth): 用户会话版本默认值对齐 main,收敛 dev 血脉的 1 偏差

token_version 由 c91423a 引入时,model tag 与迁移 000052 一致都是 0;
TokenVersion 的显式赋值 1 只存在于 dev 分支的 85332df,main 上从未有过。
本次把用户侧(users 表)统一收敛到 0,管理员侧(admin_users)保持不动。

- model/user.go:TokenVersion 的 gorm tag 由 default:1 改为 default:0
- auth/repository.go:FindOrCreateByPhone / RegisterWithPassword 移除
  显式 TokenVersion: 1,改由列默认值决定

行为收敛:此前 listing/mutation.go 的建号路径完全不显式赋值,
落库值取决于 DB 列默认值(本机 1 / 迁移定义 0),是真实的行为漂移来源;
现在三条建号路径结果一致,均为 0。

判定依据:引入该字段的提交是否自洽 + 该值是否在 main 上,
不以本机库的实际列定义为准(本地曾被手工改成 1)。
This commit is contained in:
yml2213
2026-09-10 13:26:16 +08:00
parent 7ffc3822f5
commit 2b8c74a0f1
2 changed files with 3 additions and 4 deletions
@@ -83,7 +83,6 @@ func (r *UserRepository) FindOrCreateByPhone(ctx context.Context, phone string,
CreditScore: 100,
Status: "active",
RegisterTrackCode: code,
TokenVersion: 1,
LastLoginAt: &now,
}
@@ -138,7 +137,6 @@ func (r *UserRepository) RegisterWithPassword(ctx context.Context, phone string,
CreditScore: 100,
Status: "active",
RegisterTrackCode: code,
TokenVersion: 1,
LastLoginAt: &now,
}