package home import ( "site/app/models" "site/core" ) type BookModel struct { *core.Model ID int `json:"id"` Name string `json:"name"` } func (b *BookModel) TableName() string { return "book" } func (b *BookModel) GetBookById(id int) *BookModel { book := new(BookModel) models.DB.Where("id", id).Find(&book) return book }