topfans/backend/services/notificationService/model/user_device.go

22 lines
1.2 KiB
Go

package model
// UserDevice 用户推送设备标识。
//
// 字段约定:
// - CID:由 App 端调用 uni.getPushClientId() 获取的推送 token,用于 uniCloud sendMessage。
// - Platform:ios / android / harmony,便于后续按平台分组推送或排查问题。
// - Active:false 表示设备下线(登出 / token 失效),推送时跳过。
type UserDevice struct {
ID int64 `json:"id" gorm:"primaryKey;column:id"`
UserID int64 `json:"user_id" gorm:"column:user_id;not null;index"`
CID string `json:"cid" gorm:"column:cid;not null;size:128;uniqueIndex"`
Platform string `json:"platform" gorm:"column:platform;not null;size:20;default:''"`
AppVersion string `json:"app_version" gorm:"column:app_version;not null;size:32;default:''"`
DeviceModel string `json:"device_model" gorm:"column:device_model;not null;size:64;default:''"`
Active bool `json:"active" gorm:"column:active;not null;default:true"`
CreatedAt int64 `json:"created_at" gorm:"column:created_at;not null"`
UpdatedAt int64 `json:"updated_at" gorm:"column:updated_at;not null"`
}
// TableName 表名
func (UserDevice) TableName() string { return "public.user_devices" }