tercul-backend/internal/models/location.go
Damir Mukimov fa336cacf3
wip
2025-09-01 00:43:59 +02:00

65 lines
1.8 KiB
Go

package models
// Country represents a country
type Country struct {
TranslatableModel
Name string `gorm:"size:100;not null"`
Code string `gorm:"size:2;not null;uniqueIndex"`
PhoneCode string `gorm:"size:10"`
Currency string `gorm:"size:3"`
Continent string `gorm:"size:20"`
// Relationships
Cities []*City `gorm:"foreignKey:CountryID"`
Places []*Place `gorm:"foreignKey:CountryID"`
Addresses []*Address `gorm:"foreignKey:CountryID"`
}
// Language represents a normalized language reference (ISO-639)
type Language struct {
BaseModel
Code string `gorm:"size:16;not null;uniqueIndex"` // e.g., en, en-US, eng
Name string `gorm:"size:100;not null"`
Script string `gorm:"size:20"` // Latn, Cyrl
Direction string `gorm:"size:5"` // ltr, rtl
}
// City represents a city
type City struct {
TranslatableModel
Name string `gorm:"size:100;not null"`
CountryID uint
Country *Country `gorm:"foreignKey:CountryID"`
// Relationships
Places []*Place `gorm:"foreignKey:CityID"`
Addresses []*Address `gorm:"foreignKey:CityID"`
}
// Place represents a specific place (landmark, building, etc.)
type Place struct {
TranslatableModel
Name string `gorm:"size:100;not null"`
Description string `gorm:"type:text"`
Latitude float64
Longitude float64
CountryID *uint
Country *Country `gorm:"foreignKey:CountryID"`
CityID *uint
City *City `gorm:"foreignKey:CityID"`
}
// Address represents a physical address
type Address struct {
BaseModel
Street string `gorm:"size:255"`
StreetNumber string `gorm:"size:20"`
PostalCode string `gorm:"size:20"`
CountryID *uint
Country *Country `gorm:"foreignKey:CountryID"`
CityID *uint
City *City `gorm:"foreignKey:CityID"`
Latitude *float64
Longitude *float64
}