models

package
v0.0.0-...-4cd3371 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"`
	ID        uuid.UUID  `gorm:"primary_key;type:uuid;" json:"id"`
}

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(tx *gorm.DB) (err error)

type Car

type Car struct {
	Base
	Status       *CarStatusEnums   `json:"status" gorm:"type:varchar(10);not null"`
	Name         *string           `json:"name" gorm:"type:varchar(255);not null"`
	Fuel         FuelEnums         `json:"fuel" gorm:"not null"`
	Transmission TransmissionEnums `json:"transmission" gorm:"not null"`

	VendorID uuid.UUID `json:"vendor_id" gorm:"not null"`
	Vendor   Vendor    `json:"vendor" gorm:"foreignkey:VendorID"`

	OfficeID uuid.UUID `json:"office_id" gorm:"not null"`
	Office   Office    `json:"office" gorm:"foreignkey:OfficeID"`
}

type CarStatusEnums

type CarStatusEnums string
const (
	CarStatusAvailable CarStatusEnums = "available"
	CarStatusRented    CarStatusEnums = "rented"
)

func (*CarStatusEnums) IsValid

func (c *CarStatusEnums) IsValid() bool

type Driver

type Driver struct {
	Base
	FirstName            *string   `json:"first_name" gorm:"type:varchar(255);not null"`
	LastName             *string   `json:"last_name" gorm:"type:varchar(255);not null"`
	Email                *string   `json:"email" gorm:"type:varchar(255);not null;"`
	Phone                *string   `json:"phone" gorm:"type:varchar(255);not null"`
	IdentificationNumber *string   `json:"identification_number" gorm:"type:varchar(11);not null"`
	Birthday             *JsonDate `json:"birthday" gorm:"not null"`
}

type FuelEnums

type FuelEnums string
const (
	Gas      FuelEnums = "gas"
	Diesel   FuelEnums = "diesel"
	Electric FuelEnums = "electric"
)

func (*FuelEnums) IsValid

func (f *FuelEnums) IsValid() bool

func (*FuelEnums) String

func (f *FuelEnums) String() string

type JsonDate

type JsonDate time.Time

func (JsonDate) FromString

func (t JsonDate) FromString(s string) JsonDate

FromString converts string to JsonDate

func (JsonDate) FromTime

func (t JsonDate) FromTime(t2 time.Time) JsonDate

FromTime converts time.Time to JsonDate

func (JsonDate) MarshalJSON

func (t JsonDate) MarshalJSON() ([]byte, error)

func (JsonDate) String

func (t JsonDate) String() string

func (JsonDate) ToTime

func (t JsonDate) ToTime() time.Time

ToTime converts JsonDate to time.Time

func (*JsonDate) UnmarshalJSON

func (t *JsonDate) UnmarshalJSON(data []byte) error

type JsonTime

type JsonTime time.Time

func (JsonTime) FromString

func (t JsonTime) FromString(s string) JsonTime

FromString converts string to JsonTime

func (JsonTime) MarshalJSON

func (t JsonTime) MarshalJSON() ([]byte, error)

func (JsonTime) String

func (t JsonTime) String() string

func (JsonTime) ToTime

func (t JsonTime) ToTime() time.Time

ToTime converts JsonTime to time.Time

func (*JsonTime) UnmarshalJSON

func (t *JsonTime) UnmarshalJSON(data []byte) error

type Location

type Location struct {
	Base
	Name     *string `json:"name" gorm:"type:varchar(255);not null;unique"`
	IsActive bool    `json:"is_active" gorm:"type:boolean;"`
}

type Office

type Office struct {
	Base
	OpeningHours JsonTime `json:"opening_hours"`
	ClosingHours JsonTime `json:"closing_hours"`

	VendorID uuid.UUID `json:"vendor_id" gorm:"not null"`
	Vendor   Vendor    `json:"vendor" gorm:"foreignkey:VendorID"`

	LocationID uuid.UUID `json:"location_id" gorm:"not null"`
	Location   Location  `json:"location" gorm:"foreignkey:LocationID"`

	WorkingDays []WorkingDay `json:"working_days" gorm:"many2many:office_working_days"`
}

func (*Office) GetWorkingDays

func (o *Office) GetWorkingDays() []WorkingDay

GetWorkingDays returns the working days of the office.

func (*Office) IsAvaliable

func (o *Office) IsAvaliable(date, time time.Time) bool

IsAvaliable returns true if the office is available at the given time.

type Reservation

type Reservation struct {
	Base
	Status ReservationStatus `json:"status"`

	PickupLocationID uuid.UUID `json:"pickup_location_id"`
	PickupLocation   Location  `json:"pickup_location" gorm:"foreignkey:PickupLocationID"`

	PickupDate JsonDate `json:"pickup_date"`
	PickupTime JsonTime `json:"pickup_time"`

	DropoffLocationID uuid.UUID `json:"dropoff_location_id"`
	DropoffLocation   Location  `json:"dropoff_location" gorm:"foreignkey:DropoffLocationID"`

	DropoffDate JsonDate `json:"dropoff_date"`
	DropoffTime JsonTime `json:"dropoff_time"`

	DriverID uuid.UUID `json:"driver_id"`
	Driver   Driver    `json:"driver" gorm:"foreignkey:DriverID"`

	CarID uuid.UUID `json:"car_id"`
	Car   Car       `json:"car" gorm:"foreignkey:CarID"`
}

type ReservationStatus

type ReservationStatus string
const (
	ReservationStatusPending   ReservationStatus = "pending"
	ReservationStatusConfirmed ReservationStatus = "confirmed"
	ReservationStatusCancelled ReservationStatus = "cancelled"
)

type TransmissionEnums

type TransmissionEnums string
const (
	Automatic TransmissionEnums = "automatic"
	Manual    TransmissionEnums = "manual"
)

func (*TransmissionEnums) IsValid

func (t *TransmissionEnums) IsValid() bool

func (*TransmissionEnums) String

func (t *TransmissionEnums) String() string

type Vendor

type Vendor struct {
	Base
	Name *string `json:"name" gorm:"type:varchar(255);not null;unique"`
}

type WorkingDay

type WorkingDay struct {
	gorm.Model
	Day   string `json:"day" gorm:"type:varchar(10);not null"`
	Value uint   `json:"value" gorm:"type:integer;not null;unique"`

	Offices []Office `json:"offices" gorm:"many2many:office_working_days"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL