package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type C2ItemModel interface { List(db *gorm.DB) ([]C2Item, error) } type C2Item struct { ID int64 `gorm:"column:id" json:"id"` Name string `gorm:"column:name" json:"name"` } type defaultC2ItemModel struct { tabname string fields string } func NewC2ItemModel() C2ItemModel { return &defaultC2ItemModel{ tabname: "db_adm_dws.t_adm_ads6", fields: "id, name", } } func (d *defaultC2ItemModel) List(db *gorm.DB) ([]C2Item, error) { var res []C2Item err := database.List(db, &res, database.Option{ TableName: d.tabname, Fields: d.fields, }) return res, err }