package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Ads17Model interface { Get(db *gorm.DB) (*AdmAds17, error) List(db *gorm.DB) ([]AdmAds17, error) Count(db *gorm.DB) (int64, error) Update(db *gorm.DB, values interface{}) error } type AdmAds17 struct { ID int64 `gorm:"column:id" json:"id" form:"id"` Vin string `gorm:"column:vin" json:"vin" form:"vin"` InsuranceDate string `gorm:"column:insurance_date" json:"insurance_date" form:"insurance_date"` 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 defaultAds17 struct { tableName string fields string } func NewAds17Model() Ads17Model { return &defaultAds17{ tableName: "t_adm_ads17", fields: "id, vin, insurance_date, created_at, updated_at", } } func (d *defaultAds17) Get(db *gorm.DB) (*AdmAds17, error) { var res AdmAds17 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultAds17) List(db *gorm.DB) ([]AdmAds17, error) { var res []AdmAds17 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return res, err } func (d *defaultAds17) Count(db *gorm.DB) (int64, error) { return database.Count(db, database.Option{ TableName: d.tableName, }) } func (d *defaultAds17) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }