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:
@ -50,7 +50,7 @@ func (r *NotificationRepo) CountUnread(userID uint) (int64, error) {
|
||||
// MarkRead 标记单条消息为已读
|
||||
func (r *NotificationRepo) MarkRead(id, userID uint) error {
|
||||
return r.db.Model(&model.Notification{}).
|
||||
Where("uid = ? AND user_id = ?", id, userID).
|
||||
Where("id = ? AND user_id = ?", id, userID).
|
||||
Update("is_read", true).Error
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ func (r *NotificationRepo) GetUsernameByID(userID uint) (string, error) {
|
||||
// GetNotifyPrefs 获取用户通知偏好(NotifyPrefs 字段原始 JSON)
|
||||
func (r *NotificationRepo) GetNotifyPrefs(userID uint) (string, error) {
|
||||
var prefs string
|
||||
err := r.db.Table("users").Select("notify_prefs").Where("uid = ?", userID).Scan(&prefs).Error
|
||||
err := r.db.Table("users").Select("notify_prefs").Where("id = ?", userID).Scan(&prefs).Error
|
||||
return prefs, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user