package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Dws1Model interface { Get(db *gorm.DB) (*AdmDws1, error) List(db *gorm.DB) ([]AdmDws1, error) Count(db *gorm.DB) (int64, error) Update(db *gorm.DB, values interface{}) error } type AdmDws1 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 defaultDws1 struct { tableName string fields string } func NewDws1Model() Dws1Model { return &defaultDws1{ tableName: "t_adm_dws1", fields: "id, plate_no, plate_type, vin, source, created_at, updated_at", } } func (d *defaultDws1) Get(db *gorm.DB) (*AdmDws1, error) { var res AdmDws1 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultDws1) List(db *gorm.DB) ([]AdmDws1, error) { var res []AdmDws1 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return res, err } func (d *defaultDws1) Count(db *gorm.DB) (int64, error) { return database.Count(db, database.Option{ TableName: d.tableName, }) } func (d *defaultDws1) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }