address.go 1.2 KB

123456789101112131415161718192021222324252627
  1. package request
  2. import "time"
  3. type Location struct {
  4. ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
  5. AddressID int64 `gorm:"not null" json:"address_id"`
  6. Lon float32 `json:"lon"` // 经度(Longitude)
  7. Lat float32 `json:"lat"` // 纬度(Latitude)
  8. CreatedAt time.Time `json:"created_at"`
  9. UpdatedAt *time.Time `json:"updated_at"`
  10. }
  11. type Address struct {
  12. ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
  13. UserID int64 `gorm:"not null" json:"user_id"`
  14. Country string `json:"country"` // 国家
  15. Province string `json:"province"` // 省
  16. City string `json:"city"` // 市
  17. District string `json:"district"` // 区
  18. Street string `json:"street"` // 街道
  19. Remark string `json:"remark"` // 详细地址
  20. Location Location `gorm:"foreignKey:AddressID" json:"location"` // 地理位置
  21. IsDefault int32 `json:"is_default"` // 默认地址 0 | 1
  22. CreatedAt time.Time `json:"created_at"`
  23. UpdatedAt *time.Time `json:"updated_at"`
  24. }