package model import ( "time" "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type Ads13Model interface { Get(db *gorm.DB) (*Ads13, error) Insert(db *gorm.DB, datab interface{}) error Update(db *gorm.DB, values interface{}) error } type Ads13 struct { ID int64 `gorm:"column:id" json:"id" form:"id"` StyleId string `gorm:"column:style_id" json:"style_id" form:"style_id"` StartMile int64 `gorm:"column:start_mile" json:"start_mile" form:"start_mile"` StartDate int64 `gorm:"column:start_date" json:"start_date" form:"start_date"` MaintainMileMinCycle int64 `gorm:"column:maintain_mile_min_cycle" json:"maintain_mile_min_cycle" form:"maintain_mile_min_cycle"` MaintainDateMinCycle int64 `gorm:"column:maintain_date_min_cycle" json:"maintain_date_min_cycle" form:"maintain_date_min_cycle"` WashCycle int64 `gorm:"column:wash_cycle" json:"wash_cycle" form:"wash_cycle"` RepairCycle int64 `gorm:"column:repair_cycle" json:"repair_cycle" form:"repair_cycle"` CreatedAt time.Time `gorm:"column:created_at" json:"created_at" form:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" form:"updated_at"` } type defalutAds13Model struct { tableName string fileds string } func NewAds13Model() Ads13Model { return &defalutAds13Model{ tableName: "t_adm_ads13", fileds: "id, style_id, start_mile, start_date, maintain_mile_min_cycle, maintain_date_min_cycle, wash_cycle, repair_cycle, created_at, updated_at", } } func (d *defalutAds13Model) Get(db *gorm.DB) (*Ads13, error) { var res Ads13 err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fileds, }) return &res, err } func (d *defalutAds13Model) Insert(db *gorm.DB, data interface{}) error { return database.Create(db, data, database.Option{ TableName: d.tableName, }) } func (d *defalutAds13Model) Update(db *gorm.DB, values interface{}) error { return database.Update(db, values, database.Option{ TableName: d.tableName, }) }