2026-03-09 21:28:58 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// UserSticker 用户自定义表情
|
|
|
|
|
type UserSticker struct {
|
|
|
|
|
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
|
|
|
|
UserID string `json:"user_id" gorm:"type:varchar(36);not null;index:idx_user_stickers"`
|
|
|
|
|
URL string `json:"url" gorm:"type:text;not null"`
|
|
|
|
|
Width int `json:"width" gorm:"default:0"`
|
|
|
|
|
Height int `json:"height" gorm:"default:0"`
|
|
|
|
|
SortOrder int `json:"sort_order" gorm:"default:0;index:idx_user_stickers_sort"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TableName 表名
|
|
|
|
|
func (UserSticker) TableName() string {
|
|
|
|
|
return "user_stickers"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BeforeCreate 创建前生成UUID
|
|
|
|
|
func (s *UserSticker) BeforeCreate(tx *gorm.DB) error {
|
2026-05-04 13:07:03 +08:00
|
|
|
SetUUIDIfEmpty(&s.ID)
|
2026-03-09 21:28:58 +08:00
|
|
|
return nil
|
|
|
|
|
}
|