90a96b4125
- Remove api_es service, Dockerfile, all Go source files - Remove api_es from docker-compose.yml, nginx-ssl.conf, .env, Makefile - Replace nginx /api/ proxy with /api/v1/ → api_yal:8787 - Add amenity/upload domains, AuthResponse, GET /auth/me, GET /objects/my to api_yal - Rewrite easysite frontend: types, composables, and all 5 pages to use api_yal DTOs - Wire nuxt.config public.apiBase, add useObjects CRUD composable - Update docs references from api_es to api_yal
88 lines
3.1 KiB
Go
88 lines
3.1 KiB
Go
package models
|
||
|
||
import ()
|
||
|
||
type ObjectStatus string
|
||
|
||
const (
|
||
ObjectStatusDraft ObjectStatus = "draft"
|
||
ObjectStatusModeration ObjectStatus = "moderation"
|
||
ObjectStatusActive ObjectStatus = "active"
|
||
ObjectStatusInactive ObjectStatus = "inactive"
|
||
ObjectStatusRejected ObjectStatus = "rejected"
|
||
)
|
||
|
||
type Object struct {
|
||
/*ID, CreatedAt, UpdatedAt, DeletedAt (Update's history)*/
|
||
Base `gorm:"embedded"`
|
||
|
||
// owner account ID
|
||
OwnerID uint `json:"owner_id"`
|
||
Owner Account `gorm:"foreignKey:OwnerID;references:ID" json:"owner"`
|
||
|
||
// Основная информация
|
||
Title string `gorm:"default:''" json:"title"`
|
||
ShortName string `gorm:"not null" json:"short_name"`
|
||
LongName string `json:"long_name"`
|
||
Type string `json:"type"`
|
||
|
||
// Цена
|
||
Price float64 `gorm:"default:0" json:"price"`
|
||
PricePeriod string `gorm:"default:'per_unit'" json:"price_period"`
|
||
|
||
// контактные данные
|
||
Phone string `json:"phone"`
|
||
Email string `json:"email"`
|
||
|
||
// ссылка на сайт
|
||
Site string `json:"site"`
|
||
// короткое описание
|
||
ShortDescription string `json:"short_description"`
|
||
// полное описание
|
||
Description string `json:"description"`
|
||
// адресс
|
||
Address string `json:"address"`
|
||
// Геолокация долгота и широта
|
||
Latitude float64 `json:"latitude"`
|
||
Longitude float64 `json:"longitude"`
|
||
|
||
// Статус объекта
|
||
IsActive bool `gorm:"default:true;index" json:"is_active"`
|
||
IsVerified bool `gorm:"default:false" json:"is_verified"`
|
||
Status ObjectStatus `gorm:"default:active" json:"status"`
|
||
ViewCount int `gorm:"default:0" json:"view_count"`
|
||
|
||
// Связи с рейтингами (для разных платформ)
|
||
TouristRating *Rating `gorm:"foreignKey:ObjectID;references:ID;where:platform='tourist'" json:"tourist_rating,omitempty"`
|
||
EntrepreneurRating *Rating `gorm:"foreignKey:ObjectID;references:ID;where:platform='entrepreneur'" json:"entrepreneur_rating,omitempty"`
|
||
|
||
// Все рейтинги объекта (если нужно получить оба сразу)
|
||
Ratings []Rating `gorm:"foreignKey:ObjectID" json:"ratings,omitempty"`
|
||
|
||
// Связи с отзывами
|
||
Feedbacks []Feedback `gorm:"foreignKey:ObjectID" json:"feedbacks,omitempty"`
|
||
FeedbackCount int `gorm:"default:0" json:"feedback_count"`
|
||
|
||
// Изображения
|
||
Images []ObjectImage `gorm:"foreignKey:ObjectID" json:"images,omitempty"`
|
||
|
||
// Удобства (many-to-many)
|
||
Amenities []Amenity `gorm:"many2many:object_amenities;" json:"amenities,omitempty"`
|
||
}
|
||
|
||
type ObjectImage struct {
|
||
Base `gorm:"embedded"`
|
||
ObjectID uint `gorm:"not null;index" json:"object_id"`
|
||
URL string `gorm:"not null" json:"url"`
|
||
IsPrimary bool `gorm:"default:false" json:"is_primary"`
|
||
SortOrder int `gorm:"default:0" json:"sort_order"`
|
||
}
|
||
|
||
type Amenity struct {
|
||
ID uint `gorm:"primaryKey" json:"id"`
|
||
Name string `gorm:"uniqueIndex;not null" json:"name"`
|
||
Category string `json:"category"`
|
||
Icon string `json:"icon"`
|
||
Description string `json:"description"`
|
||
}
|