refactor: BaseModel 主键列名统一 uid→id

- BaseModel 移除 gorm column:uid 和 json:uid 标签,统一为 id
- 更新 8 个 repository 文件中 28 处 raw SQL 列引用 (uid→id)
- 更新 3 个前端 JS 文件中 14 处 API 响应字段引用 (uid→id)
- 添加数据库迁移 SQL 脚本 (docs/migrations/001_uid_to_id.sql)
This commit is contained in:
2026-06-02 19:17:57 +08:00
parent 7fdea90ded
commit 5911cee01c
13 changed files with 70 additions and 43 deletions

View File

@ -66,7 +66,7 @@ func (r *EnergyRepo) FindPostByID(postID uint) (*model.Post, error) {
// AddEnergy 原子增减用户域能余额amount 可为正负)
func (r *EnergyRepo) AddEnergy(userID uint, amount int) error {
return r.db.Model(&model.User{}).
Where("uid = ?", userID).
Where("id = ?", userID).
UpdateColumn("energy", gorm.Expr("energy + ?", amount)).Error
}