package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Dws9Model interface { Get(db *gorm.DB) (*Dws9, error) List(db *gorm.DB) ([]Dws9, error) } type Dws9 struct { ID int64 `gorm:"column:id" json:"id"` Vin string `gorm:"column:vin" json:"vin"` ThirdStyleId string `gorm:"column:third_style_id" json:"third_style_id"` Source string `gorm:"column:source" json:"source"` } type defaultDws9Model struct { tableName string fields string } func NewDws9Model() Dws9Model { return &defaultDws9Model{ "t_adm_dws9", "id, vin, third_style_id, source", } } func (d *defaultDws9Model) Get(db *gorm.DB) (*Dws9, error) { var res Dws9 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err } func (d *defaultDws9Model) List(db *gorm.DB) ([]Dws9, error) { var res []Dws9 err := database.List(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return res, err }