package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Dws20Model interface { Get(db *gorm.DB) (*AdmDws20, error) List(db *gorm.DB, pagination *Pagination) ([]AdmDws20, error) Count(db *gorm.DB) (int64, error) Update(db *gorm.DB, values interface{}) error } type AdmDws20 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 defaultDws20 struct { tableName string fields string } func NewDws20Model() Dws20Model { return &defaultDws20{ tableName: "t_adm_dws20", fields: "id, initial, brand_name, brand_id, weight, has_img, old_brand_name, status, update_time", } } func (d *defaultDws20) Get(db *gorm.DB) (*AdmDws20, error) { var res AdmDws20 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultDws20) List(db *gorm.DB, pagination *Pagination) ([]AdmDws20, error) { var res []AdmDws20 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, Limit: pagination.Limit, OffSet: pagination.Offset, }) return res, err } func (d *defaultDws20) Count(db *gorm.DB) (int64, error) { return database.Count(db, database.Option{ TableName: d.tableName, }) } func (d *defaultDws20) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }