Skip to content

Commit

Permalink
Add flight code
Browse files Browse the repository at this point in the history
  • Loading branch information
boozec committed Apr 14, 2024
1 parent 4e188c9 commit 24dd3e4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/models/flight.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// Flight model
type Flight struct {
Id uint `gorm:"column:id" json:"id"`
Code string `gorm:"code" json:"code"`
CreatedAt time.Time `gorm:"column:created_at" json:"crated_at"`
DepartaureTime time.Time `gorm:"column:departaure_time" json:"departaure_time"`
ArrivalTime time.Time `gorm:"column:arrival_time" json:"arrival_time"`
Expand All @@ -28,6 +29,7 @@ type FlightValidationInput interface {

// Struct used to get new data for a flight
type FlightInput struct {
Code string `json:"code" binding:"required"`
DepartaureTime time.Time `json:"departaure_time" binding:"required"`
ArrivalTime time.Time `json:"arrival_time" binding:"required"`
DepartaureAirportId int `json:"departaure_airport_id" binding:"required"`
Expand Down Expand Up @@ -89,6 +91,7 @@ func ValidateFlight(db *gorm.DB, in FlightValidationInput) error {
func NewFlight(in FlightInput) Flight {
return Flight{
CreatedAt: time.Now(),
Code: in.Code,
DepartaureTime: in.DepartaureTime,
DepartaureAirportId: in.DepartaureAirportId,
ArrivalTime: in.ArrivalTime,
Expand Down

0 comments on commit 24dd3e4

Please sign in to comment.