added structs functions
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user