models

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPasswordCost    = 12
	DefaultExpirationDelta = 30 * 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Model
	VehicleUUID uuid.UUID `gorm:"not null;" json:"vehicleUUID"`
	Vehicle     Vehicle   `gorm:"foreignKey:VehicleUUID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	Key         string    `gorm:"not null;" json:"apiKey"`
}

func (*APIKey) BeforeSave

func (ak *APIKey) BeforeSave(tx *gorm.DB) error

type Location

type Location struct {
	Model
	VehicleUUID uuid.UUID     `gorm:"not null;" json:"vehicle_uuid"`
	Vehicle     Vehicle       `gorm:"foreignKey:VehicleUUID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	Latitude    float64       `gorm:"not null;" json:"latitude"`
	Longitude   float64       `gorm:"not null;" json:"longitude"`
	Speed       float64       `gorm:"not null;" json:"speed"`
	Status      VehicleStatus `gorm:"not null;" json:"status"`
}

type Model

type Model struct {
	UUID      uuid.UUID  `gorm:"primaryKey" json:"uuid"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `sql:"index" json:"-"`
}

func (*Model) BeforeSave

func (m *Model) BeforeSave(tx *gorm.DB) error

type Route

type Route struct {
	Model
	VehicleUUID uuid.UUID   `gorm:"not null;" json:"vehicle_uuid"`
	Vehicle     Vehicle     `gorm:"foreignKey:VehicleUUID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	Started     time.Time   `gorm:"default:CURRENT_TIMESTAMP;not null;" json:"started"`
	Completed   *time.Time  `json:"completed,omitempty"`
	Status      RouteStatus `gorm:"not null;" json:"status"`
	StartNode   int         `gorm:"not null;" json:"startNode"`
	EndNode     int         `gorm:"not null;" json:"endNode"`
}

type RouteStatus

type RouteStatus int
const (
	RouteInProgress RouteStatus = iota
	RouteCancelled
	RouteCompleted
)

type User

type User struct {
	Model
	Username     string   `gorm:"unique;not null;" json:"username"`
	Password     string   `gorm:"-" json:"password"`
	PasswordHash []byte   `gorm:"not null;" json:"-"`
	Type         UserType `gorm:"not null;" json:"account_type"`
}

func (*User) Authenticate

func (u *User) Authenticate(password string) bool

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) error

func (*User) Claims

func (u *User) Claims() jwt.MapClaims

func (*User) FromClaims

func (u *User) FromClaims(m jwt.MapClaims) error

type UserType

type UserType int
const (
	Admin UserType = iota
	Manager
)

type Vehicle

type Vehicle struct {
	Model
	Name  string `gorm:"not null;" json:"name"`
	Plate string `gorm:"not null;unique" json:"plate"`
}

func (*Vehicle) BeforeSave

func (v *Vehicle) BeforeSave(tx *gorm.DB) error

type VehicleStatus

type VehicleStatus int
const (
	EngineOn VehicleStatus = iota
	EngineOff
)

Jump to

Keyboard shortcuts

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