dws1.go 1.7 KB

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