Initial commit

This commit is contained in:
2022-08-12 14:49:16 +02:00
commit b9b0c10e1c
22 changed files with 3737 additions and 0 deletions

25
storage/vehicles.go Normal file
View File

@@ -0,0 +1,25 @@
package storage
import "time"
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 (v Vehicle) Free(start time.Time, end time.Time) bool {
for _, b := range v.Bookings {
if (start.After(b.Unavailablefrom) && start.Before(b.Unavailableto)) ||
(end.After(b.Unavailablefrom) && end.Before(b.Unavailableto)) ||
(start.Before(b.Unavailablefrom) && end.After(b.Unavailableto)) {
return false
}
}
return true
}