added structs functions

This commit is contained in:
2026-01-25 22:41:20 +01:00
parent b6cfcc196b
commit 65d301542e
+14
View File
@@ -1,5 +1,7 @@
package models
import "bamort/database"
type GameSystem struct {
ID uint `gorm:"primaryKey"`
Code string `gorm:"uniqueIndex;size:100;not null"`
@@ -14,3 +16,15 @@ type GameSystem struct {
func (GameSystem) TableName() string {
return "game_systems"
}
func (gs *GameSystem) FirstByCode(code string) error {
return database.DB.First(gs, "code = ?", code).Error
}
func (gs *GameSystem) GetDefault() error {
return database.DB.First(gs, "is_active = ?", true).Error
}
func (gs *GameSystem) FirstByName(name string) error {
return database.DB.First(gs, "name = ?", name).Error
}