ads17.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type Ads17Model interface {
  7. Get(db *gorm.DB) (*AdmAds17, error)
  8. List(db *gorm.DB) ([]AdmAds17, error)
  9. Count(db *gorm.DB) (int64, error)
  10. Update(db *gorm.DB, values interface{}) error
  11. }
  12. type AdmAds17 struct {
  13. ID int64 `gorm:"column:id" json:"id" form:"id"`
  14. Vin string `gorm:"column:vin" json:"vin" form:"vin"`
  15. InsuranceDate string `gorm:"column:insurance_date" json:"insurance_date" form:"insurance_date"`
  16. CreatedAt int64 `gorm:"column:created_at" json:"created_at" form:"created_at"`
  17. UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at" form:"updated_at"`
  18. }
  19. type defaultAds17 struct {
  20. tableName string
  21. fields string
  22. }
  23. func NewAds17Model() Ads17Model {
  24. return &defaultAds17{
  25. tableName: "t_adm_ads17",
  26. fields: "id, vin, insurance_date, created_at, updated_at",
  27. }
  28. }
  29. func (d *defaultAds17) Get(db *gorm.DB) (*AdmAds17, error) {
  30. var res AdmAds17
  31. err := database.Get(db, &res, database.Option{
  32. TableName: d.tableName,
  33. Fields: d.fields,
  34. })
  35. return &res, err
  36. }
  37. func (d *defaultAds17) List(db *gorm.DB) ([]AdmAds17, error) {
  38. var res []AdmAds17
  39. err := database.List(db, &res, database.Option{
  40. TableName: d.tableName,
  41. Fields: d.fields,
  42. })
  43. return res, err
  44. }
  45. func (d *defaultAds17) Count(db *gorm.DB) (int64, error) {
  46. return database.Count(db, database.Option{
  47. TableName: d.tableName,
  48. })
  49. }
  50. func (d *defaultAds17) Update(db *gorm.DB, values interface{}) error {
  51. return database.Update(db, values, database.Option{
  52. TableName: d.tableName,
  53. })
  54. }