Documentation
¶
Index ¶
- Constants
- type Booking
- type MongoDBStorage
- func (s MongoDBStorage) CreateBooking(booking Booking) error
- func (s MongoDBStorage) CreateVehicle(vehicle Vehicle) error
- func (s MongoDBStorage) DeleteBooking(bookingid string) error
- func (s MongoDBStorage) GetBooking(id string) (*Booking, error)
- func (s MongoDBStorage) GetBookings() (bookings []Booking, err error)
- func (s MongoDBStorage) GetBookingsForDriver(driver string) (bookings []Booking, err error)
- func (s MongoDBStorage) GetBookingsForVehicle(vehicleid string) (bookings []Booking, err error)
- func (s MongoDBStorage) GetVehicle(id string) (*Vehicle, error)
- func (s MongoDBStorage) GetVehicles(namespaces []string) (vehicles []Vehicle, err error)
- func (s MongoDBStorage) UpdateBooking(booking Booking) error
- func (s MongoDBStorage) UpdateVehicle(vehicle Vehicle) error
- type PostgresqlStorage
- func (psql PostgresqlStorage) CreateBooking(booking Booking) error
- func (psql PostgresqlStorage) CreateVehicle(vehicle Vehicle) error
- func (psql PostgresqlStorage) DeleteBooking(id string) error
- func (psql PostgresqlStorage) GetBooking(id string) (*Booking, error)
- func (psql PostgresqlStorage) GetBookings() ([]Booking, error)
- func (psql PostgresqlStorage) GetBookingsForDriver(driver string) ([]Booking, error)
- func (psql PostgresqlStorage) GetBookingsForVehicle(vehicleid string) ([]Booking, error)
- func (psql PostgresqlStorage) GetVehicle(id string) (*Vehicle, error)
- func (psql PostgresqlStorage) GetVehicles(namespaces []string) ([]Vehicle, error)
- func (psql PostgresqlStorage) Migrate() error
- func (psql PostgresqlStorage) UpdateBooking(bookingToUpdate Booking) error
- func (psql PostgresqlStorage) UpdateVehicle(vehicle Vehicle) error
- type StatusHistoryEntry
- type Storage
- type Vehicle
- type VehicleFilters
Constants ¶
View Source
const ( StatusOld = -1 StatusOngoing = 0 StatusForthcoming = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Booking ¶
type Booking struct {
ID string `json:"id" bson:"_id"`
Vehicleid string `json:"vehicleid"`
Driver string `json:"driver"`
Startdate time.Time `json:"startdate"`
Enddate time.Time `json:"enddate"`
Data map[string]any `json:"data"`
Deleted bool `json:"deleted"`
Vehicle Vehicle `json:"vehicle" bson:"-"`
ManualStatus string `json:"manual_status" bson:"manual_status"`
StatusHistory []StatusHistoryEntry `json:"status_history" bson:"status_history"`
}
type MongoDBStorage ¶
func NewMongoDBStorage ¶
func NewMongoDBStorage(cfg *viper.Viper) (MongoDBStorage, error)
func (MongoDBStorage) CreateBooking ¶
func (s MongoDBStorage) CreateBooking(booking Booking) error
func (MongoDBStorage) CreateVehicle ¶
func (s MongoDBStorage) CreateVehicle(vehicle Vehicle) error
func (MongoDBStorage) DeleteBooking ¶
func (s MongoDBStorage) DeleteBooking(bookingid string) error
func (MongoDBStorage) GetBooking ¶
func (s MongoDBStorage) GetBooking(id string) (*Booking, error)
func (MongoDBStorage) GetBookings ¶
func (s MongoDBStorage) GetBookings() (bookings []Booking, err error)
func (MongoDBStorage) GetBookingsForDriver ¶
func (s MongoDBStorage) GetBookingsForDriver(driver string) (bookings []Booking, err error)
func (MongoDBStorage) GetBookingsForVehicle ¶
func (s MongoDBStorage) GetBookingsForVehicle(vehicleid string) (bookings []Booking, err error)
func (MongoDBStorage) GetVehicle ¶
func (s MongoDBStorage) GetVehicle(id string) (*Vehicle, error)
func (MongoDBStorage) GetVehicles ¶
func (s MongoDBStorage) GetVehicles(namespaces []string) (vehicles []Vehicle, err error)
func (MongoDBStorage) UpdateBooking ¶
func (s MongoDBStorage) UpdateBooking(booking Booking) error
func (MongoDBStorage) UpdateVehicle ¶
func (s MongoDBStorage) UpdateVehicle(vehicle Vehicle) error
///////////////////update///////////////
type PostgresqlStorage ¶
func NewPostgresqlStorage ¶
func NewPostgresqlStorage(cfg *viper.Viper) (PostgresqlStorage, error)
func (PostgresqlStorage) CreateBooking ¶
func (psql PostgresqlStorage) CreateBooking(booking Booking) error
func (PostgresqlStorage) CreateVehicle ¶
func (psql PostgresqlStorage) CreateVehicle(vehicle Vehicle) error
func (PostgresqlStorage) DeleteBooking ¶
func (psql PostgresqlStorage) DeleteBooking(id string) error
func (PostgresqlStorage) GetBooking ¶
func (psql PostgresqlStorage) GetBooking(id string) (*Booking, error)
func (PostgresqlStorage) GetBookings ¶
func (psql PostgresqlStorage) GetBookings() ([]Booking, error)
func (PostgresqlStorage) GetBookingsForDriver ¶
func (psql PostgresqlStorage) GetBookingsForDriver(driver string) ([]Booking, error)
func (PostgresqlStorage) GetBookingsForVehicle ¶
func (psql PostgresqlStorage) GetBookingsForVehicle(vehicleid string) ([]Booking, error)
func (PostgresqlStorage) GetVehicle ¶
func (psql PostgresqlStorage) GetVehicle(id string) (*Vehicle, error)
func (PostgresqlStorage) GetVehicles ¶
func (psql PostgresqlStorage) GetVehicles(namespaces []string) ([]Vehicle, error)
func (PostgresqlStorage) Migrate ¶
func (psql PostgresqlStorage) Migrate() error
func (PostgresqlStorage) UpdateBooking ¶
func (psql PostgresqlStorage) UpdateBooking(bookingToUpdate Booking) error
func (PostgresqlStorage) UpdateVehicle ¶
func (psql PostgresqlStorage) UpdateVehicle(vehicle Vehicle) error
type StatusHistoryEntry ¶
type StatusHistoryEntry struct {
FromStatus string `json:"from_status" bson:"from_status"`
ToStatus string `json:"to_status" bson:"to_status"`
UserID string `json:"user_id" bson:"user_id"`
UserName string `json:"user_name" bson:"user_name"`
GroupID string `json:"group_id" bson:"group_id"`
GroupName string `json:"group_name" bson:"group_name"`
Date time.Time `json:"date" bson:"date"`
Comment string `json:"comment" bson:"comment"`
}
type Storage ¶
type Storage interface {
//Vehicles management
CreateVehicle(Vehicle) error
GetVehicle(id string) (*Vehicle, error)
GetVehicles(namespaces []string) ([]Vehicle, error)
UpdateVehicle(Vehicle) error
//Bookings management
CreateBooking(Booking) error
UpdateBooking(Booking) error
GetBooking(id string) (*Booking, error)
GetBookings() ([]Booking, error)
GetBookingsForVehicle(vehicleid string) ([]Booking, error)
GetBookingsForDriver(driver string) ([]Booking, error)
DeleteBooking(id string) error
}
type Vehicle ¶
type Vehicle struct {
ID string `json:"id" bson:"_id"`
Type string `json:"type"`
Namespace string `json:"namespace"`
Administrators []string `json:"administrators"`
Data map[string]any `json:"data"`
Metadata map[string]any `json:"metadata"`
Bookings []Booking
}
func (Vehicle) MatchesFilters ¶
func (v Vehicle) MatchesFilters(filters VehicleFilters) bool
Click to show internal directories.
Click to hide internal directories.