package models import "time" // Photo یکی از عکس‌های پروفایل کاربر type Photo struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `gorm:"not null;index" json:"user_id"` URL string `gorm:"size:500;not null" json:"url"` SortOrder int `gorm:"default:0;not null" json:"sort_order"` CreatedAt time.Time `json:"created_at"` } func (Photo) TableName() string { return "photos" } // SwipeAction نوع تصمیمی که کاربر روی یک پروفایل دیگه گرفته type SwipeAction string const ( SwipeLike SwipeAction = "like" SwipeSuperlike SwipeAction = "superlike" SwipePass SwipeAction = "pass" ) // Swipe ثبت تصمیم یک کاربر (لایک/ردّ) روی یک کاربر دیگه. // هر جفت (SwiperID, SwipedID) فقط یک بار می‌تونه ثبت بشه؛ توی discovery feed // کسایی که قبلاً روشون تصمیم گرفته شده دیگه نشون داده نمی‌شن. type Swipe struct { ID uint `gorm:"primaryKey" json:"id"` SwiperID uint `gorm:"not null;uniqueIndex:idx_swiper_swiped" json:"swiper_id"` SwipedID uint `gorm:"not null;uniqueIndex:idx_swiper_swiped;index" json:"swiped_id"` Action SwipeAction `gorm:"size:10;not null" json:"action"` CreatedAt time.Time `json:"created_at"` } func (Swipe) TableName() string { return "swipes" } // Match وقتی ساخته می‌شه که دو کاربر متقابلاً همدیگه رو لایک کرده باشن. // UserOneID همیشه شناسه‌ی کوچیک‌تره (برای جلوگیری از رکورد تکراری در دو جهت). type Match struct { ID uint `gorm:"primaryKey" json:"id"` UserOneID uint `gorm:"not null;uniqueIndex:idx_match_pair" json:"user_one_id"` UserTwoID uint `gorm:"not null;uniqueIndex:idx_match_pair" json:"user_two_id"` CreatedAt time.Time `json:"created_at"` UserOne *User `gorm:"foreignKey:UserOneID" json:"-"` UserTwo *User `gorm:"foreignKey:UserTwoID" json:"-"` } func (Match) TableName() string { return "matches" } // Message یک پیام متنی داخل یک مچ type Message struct { ID uint `gorm:"primaryKey" json:"id"` MatchID uint `gorm:"not null;index" json:"match_id"` SenderID uint `gorm:"not null" json:"sender_id"` Text string `gorm:"size:2000;not null" json:"text"` ReadAt *time.Time `json:"read_at,omitempty"` CreatedAt time.Time `json:"created_at"` } func (Message) TableName() string { return "messages" }