package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Ads1Model interface { Get(db *gorm.DB) (*AdmAds1, error) List(db *gorm.DB) ([]AdmAds1, error) Count(db *gorm.DB) (int64, error) Update(db *gorm.DB, values interface{}) error } type AdmAds1 struct { ID int64 `gorm:"column:id" json:"id" form:"id"` PlateNo string `gorm:"column:plate_no" json:"plate_no" form:"plate_no"` PlateType string `gorm:"column:plate_type" json:"plate_type" form:"plate_type"` Vin string `gorm:"column:vin" json:"vin" form:"vin"` Source int64 `gorm:"column:source" json:"source" form:"source"` CreatedAt int64 `gorm:"column:created_at" json:"created_at" form:"created_at"` UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at" form:"updated_at"` } type defaultAds1 struct { tableName string fields string } func NewAds1Model() Ads1Model { return &defaultAds1{ tableName: "t_adm_ads1", fields: "id, plate_no, plate_type, vin, source, created_at, updated_at", } } func (d *defaultAds1) Get(db *gorm.DB) (*AdmAds1, error) { var res AdmAds1 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultAds1) List(db *gorm.DB) ([]AdmAds1, error) { var res []AdmAds1 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return res, err } func (d *defaultAds1) Count(db *gorm.DB) (int64, error) { return database.Count(db, database.Option{ TableName: d.tableName, }) } func (d *defaultAds1) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }