This commit is contained in:
2025-01-04 20:21:05 +01:00
commit a08e708a3b
11 changed files with 435 additions and 0 deletions

14
models/booking.go Normal file
View File

@@ -0,0 +1,14 @@
package models
import (
"time"
"gorm.io/gorm"
)
type Booking struct {
gorm.Model
RoomID uint `gorm:"not null"`
UserID uint `gorm:"not null"`
StartTime time.Time `gorm:"not null"`
EndTime time.Time `gorm:"not null"`
}

27
models/room.go Normal file
View File

@@ -0,0 +1,27 @@
package models
import (
"gorm.io/gorm"
"github.com/gin-gonic/gin"
)
type Room struct {
gorm.Model
Name string `json:"name" binding:"required" gorm:"unique;not null"`
Address string `json:"address"`
Website string `json:"website"`
Capacity int `json:"capacity"`
IsPublic bool `json:"isPublic" gorm:"default:false"`
Admins []User `gorm:"many2many:room_admins;"`
}
func NewRoom(ctx *gin.Context) (Room, error) {
var room Room
err := ctx.ShouldBindJSON(&room)
if err != nil {
return Room{}, err
}
return room, nil
}

12
models/user.go Normal file
View File

@@ -0,0 +1,12 @@
package models
import (
"gorm.io/gorm"
)
type User struct {
gorm.Model
Name string `json:"name" binding:"required" gorm:"unique;not null"`
Password string `json:"password" binding:"required" gorm:"not null"`
Email string `json:"email" binding:"required,email" gorm:"unique;not null"`
}