dws9.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type Dws9Model interface {
  7. Get(db *gorm.DB) (*Dws9, error)
  8. List(db *gorm.DB) ([]Dws9, error)
  9. }
  10. type Dws9 struct {
  11. ID int64 `gorm:"column:id" json:"id"`
  12. Vin string `gorm:"column:vin" json:"vin"`
  13. ThirdStyleId string `gorm:"column:third_style_id" json:"third_style_id"`
  14. Source string `gorm:"column:source" json:"source"`
  15. }
  16. type defaultDws9Model struct {
  17. tableName string
  18. fields string
  19. }
  20. func NewDws9Model() Dws9Model {
  21. return &defaultDws9Model{
  22. "t_adm_dws9",
  23. "id, vin, third_style_id, source",
  24. }
  25. }
  26. func (d *defaultDws9Model) Get(db *gorm.DB) (*Dws9, error) {
  27. var res Dws9
  28. err := database.Get(db, &res, database.Option{
  29. TableName: d.tableName,
  30. Fields: d.fields,
  31. })
  32. return &res, err
  33. }
  34. func (d *defaultDws9Model) List(db *gorm.DB) ([]Dws9, error) {
  35. var res []Dws9
  36. err := database.List(db, &res, database.Option{
  37. TableName: d.tableName,
  38. Fields: d.fields,
  39. })
  40. return res, err
  41. }