models

package
v0.0.0-...-db88faa Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Order

type Order struct {
	ID             uint          `json:"id"`
	RiderID        uint          `json:"rider_id"`
	UserID         uint          `json:"user_id"`
	RefID          string        `json:"ref_id" gorm:"uniqueIndex;size:30"`
	Status         StatusType    `json:"status" gorm:"default:Pending"`
	Item           string        `json:"item"`
	Quantity       int           `json:"quantity"`
	Charge         float64       `json:"price"`
	PaymentStatus  PaymentStatus `json:"payment_status"`
	PickUpAddress  string        `json:"pickup_address"`
	DropOffAddress string        `json:"dropoff_address"`
	CreatedAt      time.Time     `json:"created_at"`
	UpdatedAt      time.Time     `json:"updated_at"`
	Acknowledge    bool          `json:"acknowledge" gorm:"default:false"`
}

func (*Order) BeforeCreate

func (o *Order) BeforeCreate(tx *gorm.DB) (err error)

func (*Order) BeforeSave

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

func (*Order) BeforeUpdate

func (o *Order) BeforeUpdate(tx *gorm.DB) (err error)

type OrderRepo

type OrderRepo interface {
	CreateOrder(order *Order) error
	GetOrders(userID uint) ([]orderDto.OrderResponseDTO, error)
	UpdateDeliveryStatus(orderId uint, status StatusType) error
	UpdateAcknowledgeStatus(orderId uint) error
	GetOrderByID(orderId uint) (orderDto.OrderResponseDTO, error)
}

type PaymentStatus

type PaymentStatus string
const (
	Unpaid PaymentStatus = "Unpaid"
)

type Review

type Review struct {
	ID      uint    `json:"id"`
	RiderID uint    `json:"rider_id"`
	Rating  float64 `json:"rating"`
	Comment string  `json:"comment"`
}

type Rider

type Rider struct {
	ID                  uint      `json:"id" gorm:"primaryKey"`
	RiderID             string    `json:"rider_id" gorm:"uniqueIndex;size:8"`
	BikeNumber          string    `json:"bike_number"`
	FirstName           string    `json:"first_name"`
	LastName            string    `json:"last_name"`
	UserID              uint      `json:"user_id"`
	NextOfKinName       string    `json:"next_of_kin_name"`
	NextOfKinPhone      string    `json:"next_of_kin_phone"`
	DriverLicenseNumber string    `json:"driver_license_number"`
	NextOfKinAddress    string    `json:"next_of_kin_address"`
	Address             string    `json:"address"`
	SuccessfulRides     int64     `json:"successful_rides"`
	Rating              float64   `json:"rating"`
	Level               string    `json:"level"`
	CurrentLocation     string    `json:"current_location"`
	Reviews             []Review  `json:"reviews" gorm:"foreignKey:RiderID"`
	Orders              []Order   `json:"orders" gorm:"foreignKey:RiderID"`
	CreatedAt           time.Time `json:"created_at"`
	UpdatedAt           time.Time `json:"updated_at"`
	// add minimum and maximum charge to this
	MinimumCharge      float64                 `json:"minimum_charge"`
	MaximumCharge      float64                 `json:"maximum_charge"`
	AvailabilityStatus RiderAvailabilityStatus `json:"availability_status" gorm:"default:Available"`
}

func (*Rider) BeforeCreate

func (u *Rider) BeforeCreate(tx *gorm.DB) (err error)

func (*Rider) BeforeUpdate

func (r *Rider) BeforeUpdate(tx *gorm.DB) (err error)

func (*Rider) UpdateSuccessfulRides

func (r *Rider) UpdateSuccessfulRides(tx *gorm.DB) error

type RiderAvailabilityStatus

type RiderAvailabilityStatus string
const (
	Available   RiderAvailabilityStatus = "Available"
	Unavailable RiderAvailabilityStatus = "Unavailable"
	OnBreak     RiderAvailabilityStatus = "On Break"
	Busy        RiderAvailabilityStatus = "Busy"
)

type RiderRepository

type RiderRepository interface {
	CreateRider(rider *Rider) error
	GetRiders(req *http.Request) ([]dto.RiderListResponse, error)
	GetRider(id int, req *http.Request) (dto.RiderResponse, error)
	GetRiderByUserID(userID uint) (*Rider, error)
	GetRiderByID(id uint) (*Rider, error)
	UpdateRating(riderId uint) error
	UpdateMinAndMaxCharge(minCharge float64, maxCharge float64, userID uint) error
	GetRiderReviews(rideId uint) ([]Review, error)
	UpdateRiderAvailability(riderID uint, status string) error
}

type StatusType

type StatusType string
const (
	Delivered  StatusType = "Delivered"
	Canceled   StatusType = "Canceled"
	Pending    StatusType = "Pending"
	InDelivery StatusType = "InDelivery"
)

type User

type User struct {
	ID            uint      `json:"id" gorm:"primaryKey"`
	UserName      string    `json:"username"`
	Email         string    `json:"email required" gorm:"unique"`
	PhoneNumber   string    `json:"phone_number" gorm:"unique"`
	WalletBalance float64   `json:"wallet_balance"`
	AccountNumber string    `json:"account_number" gorm:""`
	AccountName   string    `json:"account_name"`
	BankName      string    `json:"bank_name"`
	Password      string    `json:"password"`
	Verified      bool      `json:"verified" gorm:"default:false"`
	Rider         Rider     `gorm:"foreignKey:UserID"`
	Orders        []Order   `json:"orders" gorm:"foreignKey:UserID"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

func (*User) BeforeCreate

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

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(tx *gorm.DB) (err error)

func (*User) Credit

func (u *User) Credit(tx *gorm.DB, amount float64) error

func (*User) Debit

func (u *User) Debit(tx *gorm.DB, amount float64) error

type UserRepo

type UserRepo interface {
	CreateUser(user *User) error
	GetUserByEmail(email string) (*User, error)
	GetUserByID(id int) (*User, error)
	CreateRating(rating *Review) error
}

Jump to

Keyboard shortcuts

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