Files
zineshop/models/room.go
2025-01-04 20:21:05 +01:00

28 lines
533 B
Go

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
}