Add PostgreSQL database option and more booking flow functionalities
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
package ocss
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type JourneyScheduleType int64
|
||||
|
||||
const (
|
||||
@@ -24,54 +18,21 @@ func (t JourneyScheduleType) MarshalJSON() ([]byte, error) {
|
||||
return []byte(types[t]), nil
|
||||
}
|
||||
|
||||
type JSONTime time.Time
|
||||
|
||||
func (t JSONTime) MarshalJSON() ([]byte, error) {
|
||||
//do your serializing here
|
||||
stamp := fmt.Sprintf("%v", time.Time(t).Unix())
|
||||
return []byte(stamp), nil
|
||||
}
|
||||
|
||||
func (t *JSONTime) UnmarshalJSON(b []byte) error {
|
||||
var timestamp int64
|
||||
err := json.Unmarshal(b, ×tamp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
parsed := time.Unix(timestamp, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsontime := JSONTime(parsed)
|
||||
*t = jsontime
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *JSONTime) ToTime() *time.Time {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
time := time.Time(*t)
|
||||
return &time
|
||||
}
|
||||
|
||||
type JourneySchedule struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
PassengerPickupDate JSONTime `json:"passengerPickupDate"`
|
||||
PassengerDepartureDate *JSONTime `json:"passengerDepartureDate,omitempty"`
|
||||
DriverDepartureDate *JSONTime `json:"driverDepartureDate,omitempty"`
|
||||
WebUrl *string `json:"webUrl,omitempty"`
|
||||
Type JourneyScheduleType `json:"type"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
PassengerPickupDate OCSSTime `json:"passengerPickupDate" bson:"passengerPickupDate"`
|
||||
//PassengerDepartureDate *OCSSTime `json:"passengerDepartureDate,omitempty"`
|
||||
DriverDepartureDate *OCSSTime `json:"driverDepartureDate,omitempty" bson:"driverDepartureDate,omitempty"`
|
||||
WebUrl *string `json:"webUrl,omitempty" bson:"webUrl,omitempty"`
|
||||
Type JourneyScheduleType `json:"type"`
|
||||
}
|
||||
|
||||
type DriverJourney struct {
|
||||
DriverTrip
|
||||
JourneySchedule
|
||||
|
||||
AvailableSteats *int64 `json:"requestedSeats,omitempty"`
|
||||
Price *Price `json:"price,omitempty"`
|
||||
AvailableSteats *int64 `json:"requestedSeats,omitempty" bson:"requestedSeats,omitempty"`
|
||||
Price *Price `json:"price,omitempty" bson:"price,omitempty"`
|
||||
}
|
||||
|
||||
type PassengerJourney struct {
|
||||
@@ -79,5 +40,5 @@ type PassengerJourney struct {
|
||||
JourneySchedule
|
||||
|
||||
//TODO how to handle requested driverDepartureDate
|
||||
RequestedSteats *int64 `json:"requestedSeats,omitempty"`
|
||||
RequestedSteats *int64 `json:"requestedSeats,omitempty" bson:"requestedSeats,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user