package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type SyBrandModel interface { List(db *gorm.DB, pagination *Pagination) ([]GdSyBrand, error) Update(db *gorm.DB, values interface{}) error } type GdSyBrand struct { ID int64 `gorm:"column:id" json:"id" form:"id"` Initial string `gorm:"column:initial" json:"initial" form:"initial"` BrandName string `gorm:"column:brand_name" json:"brand_name" form:"brand_name"` BrandId string `gorm:"column:brand_id" json:"brand_id" form:"brand_id"` Weight int64 `gorm:"column:weight" json:"weight" form:"weight"` HasImg int64 `gorm:"column:has_img" json:"has_img" form:"has_img"` Status int64 `gorm:"column:status" json:"status" form:"status"` UpdateTime string `gorm:"column:update_time" json:"update_time" form:"update_time"` } type defaultSyBrand struct { tableName string fields string } func NewSyBrand() SyBrandModel { return &defaultSyBrand{ tableName: "t_gd_sy_brand", fields: "id, initial, brand_name, brand_id, weight, has_img, status, update_time", } } func (d *defaultSyBrand) List(db *gorm.DB, pagination *Pagination) ([]GdSyBrand, error) { var res []GdSyBrand err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, Limit: pagination.Limit, OffSet: pagination.Offset, }) return res, err } func (d *defaultSyBrand) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }