dws10.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type Dws10Model interface {
  7. Get(db *gorm.DB) (*Dws10, error)
  8. List(db *gorm.DB) ([]Dws10, error)
  9. }
  10. type Dws10 struct {
  11. ID int64 `gorm:"column:id" json:"id"`
  12. ModelNo string `gorm:"column:model_no" json:"model_no"`
  13. SpySeriesId string `gorm:"column:spy_series_id" json:"spy_series_id"`
  14. SeriesId string `gorm:"column:series_id" json:"series_id"`
  15. ModelYear string `gorm:"column:model_year" json:"model_year"`
  16. DisplacementL string `gorm:"column:displacement_l" json:"displacement_l"`
  17. Vin10 string `gorm:"column:vin10" json:"vin10"`
  18. AirIntakForm string `gorm:"column:air_intak_form" json:"air_intak_form"`
  19. VinRule string `gorm:"column:vin_rule" json:"vin_rule"`
  20. }
  21. type defaultDws10Model struct {
  22. tableName string
  23. }
  24. func NewDws10Model() Dws10Model {
  25. return &defaultDws10Model{
  26. "t_adm_dws10",
  27. }
  28. }
  29. func (d *defaultDws10Model) Get(db *gorm.DB) (*Dws10, error) {
  30. var res Dws10
  31. err := database.Get(db, &res, database.Option{
  32. TableName: d.tableName,
  33. OrderBy: "model_year DESC",
  34. })
  35. return &res, err
  36. }
  37. func (d *defaultDws10Model) List(db *gorm.DB) ([]Dws10, error) {
  38. var res []Dws10
  39. err := database.List(db, &res, database.Option{
  40. TableName: d.tableName,
  41. })
  42. return res, err
  43. }