ads22.go 1010 B

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