package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Ads2Model interface { Get(db *gorm.DB) (*AdmAds2, error) List(db *gorm.DB, pagination *Pagination) ([]AdmAds2, error) Count(db *gorm.DB) (int64, error) Update(db *gorm.DB, values interface{}) error } type AdmAds2 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 int `gorm:"column:weight" json:"weight" form:"weight"` HasImg int `gorm:"column:has_img" json:"has_img" form:"has_img"` OldBrandName string `gorm:"column:old_brand_name" json:"old_brand_name" form:"old_brand_name"` Status int `gorm:"column:status" json:"status" form:"status"` UpdateTime string `gorm:"column:update_time" json:"update_time" form:"update_time"` } type defaultAds2 struct { tableName string fields string } func NewAds2Model() Ads2Model { return &defaultAds2{ tableName: "t_adm_ads2", fields: "id, initial, brand_name, brand_id, weight, has_img, old_brand_name, status, update_time", } } func (d *defaultAds2) Get(db *gorm.DB) (*AdmAds2, error) { var res AdmAds2 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultAds2) List(db *gorm.DB, pagination *Pagination) ([]AdmAds2, error) { var res []AdmAds2 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, Limit: pagination.Limit, OffSet: pagination.Offset, }) return res, err } func (d *defaultAds2) Count(db *gorm.DB) (int64, error) { return database.Count(db, database.Option{ TableName: d.tableName, }) } func (d *defaultAds2) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }