goweb/app/models/home/books.go

24 lines
341 B
Go

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
}