Files
backend/internal/model/sticker.go
lan 4d8f2ec997 Initial backend repository commit.
Set up project files and add .gitignore to exclude local build/runtime artifacts.

Made-with: Cursor
2026-03-09 21:28:58 +08:00

34 lines
929 B
Go

package model
import (
"time"
"github.com/google/uuid"
"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 {
if s.ID == "" {
s.ID = uuid.New().String()
}
return nil
}