CHANGE: added Cors

This commit is contained in:
2024-09-07 08:54:52 +02:00
parent b582e5d1c2
commit dd2fb9a79f
3 changed files with 47 additions and 21 deletions

View File

@@ -16,9 +16,9 @@ func (e SameBookingError) Error() string {
}
type Booking struct {
CardID string `json:"cradID"`
CardID string `json:"cardID"`
ReaderID string `json:"readerID"`
BookingType int `json:"bookingTyp"`
BookingType int `json:"bookingType"`
LoggedTime time.Time `json:"loggedTime"`
Id int `json:"id"`
}
@@ -123,6 +123,18 @@ func (b Booking) Save() {
}
}
func (b *Booking) Update(nb Booking) {
if b.BookingType != nb.BookingType && nb.BookingType != 0 {
b.BookingType = nb.BookingType
}
if b.CardID != nb.CardID && nb.CardID != "" {
b.CardID = nb.CardID
}
if b.ReaderID != nb.ReaderID && nb.ReaderID != "" {
b.ReaderID = nb.ReaderID
}
}
func checkLastBooking(b Booking) bool {
var booking_type int
stmt, err := DB.Prepare((`SELECT booking_type FROM "zeiten" WHERE "card_id" = $1 ORDER BY "logged_time" DESC LIMIT 1;`))