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