dws8.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type Dws8Model interface {
  7. Get(db *gorm.DB) (*AdmDws8, error)
  8. List(db *gorm.DB) ([]AdmDws8, error)
  9. Count(db *gorm.DB) (int64, error)
  10. Update(db *gorm.DB, values interface{}) error
  11. }
  12. type AdmDws8 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 defaultDws8 struct {
  20. tableName string
  21. fields string
  22. }
  23. func NewDws8Model() Dws8Model {
  24. return &defaultDws8{
  25. tableName: "t_adm_dws8",
  26. fields: "id, vin, insurance_date, created_at, updated_at",
  27. }
  28. }
  29. func (d *defaultDws8) Get(db *gorm.DB) (*AdmDws8, error) {
  30. var res AdmDws8
  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 *defaultDws8) List(db *gorm.DB) ([]AdmDws8, error) {
  38. var res []AdmDws8
  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 *defaultDws8) Count(db *gorm.DB) (int64, error) {
  46. return database.Count(db, database.Option{
  47. TableName: d.tableName,
  48. })
  49. }
  50. func (d *defaultDws8) Update(db *gorm.DB, values interface{}) error {
  51. return database.Update(db, values, database.Option{
  52. TableName: d.tableName,
  53. })
  54. }