package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Ads3Model interface { Get(db *gorm.DB) (*AdmAds3, error) List(db *gorm.DB, pagination *Pagination) ([]AdmAds3, error) Count(db *gorm.DB) (int64, error) Update(db *gorm.DB, values interface{}) error } type AdmAds3 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"` Owner string `gorm:"column:owner" json:"owner" form:"owner"` 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 defaultAds3 struct { tableName string fields string } func NewAds3Model() Ads3Model { return &defaultAds3{ tableName: "t_adm_ads3", fields: "id, plate_no, plate_type, owner, created_at, updated_at", } } func (d *defaultAds3) Get(db *gorm.DB) (*AdmAds3, error) { var res AdmAds3 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultAds3) List(db *gorm.DB, pagination *Pagination) ([]AdmAds3, error) { var res []AdmAds3 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, Limit: pagination.Limit, OffSet: pagination.Offset, }) return res, err } func (d *defaultAds3) Count(db *gorm.DB) (int64, error) { return database.Count(db, database.Option{ TableName: d.tableName, }) } func (d *defaultAds3) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }