Files
go_oxspeak_server/models/server.go
2025-11-17 01:06:03 +01:00

24 lines
488 B
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type Server struct {
ID uuid.UUID `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null" json:"name"`
Password *string `gorm:"" json:"-"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
func (s *Server) BeforeCreate(tx *gorm.DB) (err error) {
if s.ID == uuid.Nil {
s.ID = uuid.New()
}
return nil
}