implemented task 1 & 2
This commit is contained in:
parent
920dd418e4
commit
1124beeee5
12
flightRouter.go
Normal file
12
flightRouter.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterFlightRoutes(router *gin.Engine) {
|
||||||
|
router.GET("/flights", func(c *gin.Context) {
|
||||||
|
c.Status(http.StatusOK)
|
||||||
|
})
|
||||||
|
}
|
||||||
60
types.go
Normal file
60
types.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AirportModel struct {
|
||||||
|
Icao string `json:"icao" gorm:"primary_key"`
|
||||||
|
Name string `json:"name" `
|
||||||
|
Country string `json:"country"`
|
||||||
|
RunwayLength int16 `json:"runway-length"`
|
||||||
|
DateOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type PlaneModel struct {
|
||||||
|
TailNo string `json:"tail-no" gorm:"primary_key"`
|
||||||
|
Model string `json:"model"`
|
||||||
|
Manufacturer string `json:"manufacturer"`
|
||||||
|
Capacity int16 `json:"capacity"`
|
||||||
|
DateOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type FlightModel struct {
|
||||||
|
FlightNo string `json:"flight-no" gorm:"primary_key"`
|
||||||
|
Departure time.Time `json:"departure"`
|
||||||
|
Arrival *time.Time `json:"arrival"`
|
||||||
|
ArrivalAirportID string `json:"arrival-airport-id"`
|
||||||
|
ArrivalAirport AirportModel `gorm:"foreignKey:ArrivalAirportID;references:Icao"`
|
||||||
|
DepartureAirportID string `json:"departure-airport-id"`
|
||||||
|
DepartureAirport AirportModel `gorm:"foreignKey:DepartureAirportID;references:Icao"`
|
||||||
|
OperatesTailNo string `json:"operates-tail-no"`
|
||||||
|
Operates PlaneModel `gorm:"foreignKey:OperatesTailNo;references:TailNo"`
|
||||||
|
|
||||||
|
DateOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type PassengerModel struct {
|
||||||
|
Ssn string `json:"ssn" gorm:"primary_key"`
|
||||||
|
Name string `json:"name" `
|
||||||
|
DateOfBirth time.Time `json:"date-of-birth"`
|
||||||
|
isFemale *bool `json:"is-female"`
|
||||||
|
DateOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReservationModel struct {
|
||||||
|
TicketNumber int
|
||||||
|
Seat string
|
||||||
|
FlightID string
|
||||||
|
Flight FlightModel `gorm:"foreignKey:FlightID;references:FlightNo"`
|
||||||
|
PassengerID string
|
||||||
|
Passenger PassengerModel `gorm:"foreignKey:PassengerID;references:Ssn"`
|
||||||
|
DateOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type DateOptions struct {
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user