turash/bugulma/backend/internal/domain/public_transport.go
2025-12-15 10:06:41 +01:00

53 lines
2.2 KiB
Go

package domain
import (
"context"
"time"
)
// PublicTransportStop represents a common stop or station
type PublicTransportStop struct {
ID string `gorm:"primarykey;type:varchar(64)" json:"id"`
Name string `json:"name"`
NameEn string `json:"name_en"`
Type string `json:"type"`
Address string `json:"address"`
Latitude *float64 `json:"lat"`
Longitude *float64 `json:"lng"`
OsmID string `json:"osm_id"`
Estimated bool `json:"estimated"`
RoutesServed []string `gorm:"type:jsonb" json:"routes_served"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// PublicTransportRoute represents a route/service (GTFS route)
type PublicTransportRoute struct {
ID string `gorm:"primarykey;type:varchar(64)" json:"id"`
AgencyID string `json:"agency_id"`
ShortName string `json:"short_name"`
LongName string `json:"long_name"`
RouteType int `json:"route_type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// PublicTransportRepository defines data access operations for public transport data
type PublicTransportRepository interface {
// Stops
CreateStop(ctx context.Context, stop *PublicTransportStop) error
UpsertStop(ctx context.Context, stop *PublicTransportStop) error
GetStopByID(ctx context.Context, id string) (*PublicTransportStop, error)
ListStops(ctx context.Context, limit int) ([]*PublicTransportStop, error)
SearchStops(ctx context.Context, q string) ([]*PublicTransportStop, error)
SearchStopsPaginated(ctx context.Context, q string, limit, offset int) ([]*PublicTransportStop, error)
ListStopsWithinRadius(ctx context.Context, lat, lng, radiusKm float64, limit int) ([]*PublicTransportStop, error)
// Routes
CreateRoute(ctx context.Context, r *PublicTransportRoute) error
UpsertRoute(ctx context.Context, r *PublicTransportRoute) error
GetRouteByID(ctx context.Context, id string) (*PublicTransportRoute, error)
ListRoutes(ctx context.Context, limit int) ([]*PublicTransportRoute, error)
SearchRoutesPaginated(ctx context.Context, q string, limit, offset int) ([]*PublicTransportRoute, error)
}