ads12.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type Ads12Model interface {
  7. Get(db *gorm.DB) (*Ads12, error)
  8. List(db *gorm.DB, fields string) ([]Ads12, error)
  9. }
  10. type Ads12 struct {
  11. ID int64 `gorm:"column:id" json:"id"`
  12. ItemId int64 `gorm:"column:item_id" json:"item_id"`
  13. ItemName string `gorm:"column:item_name" json:"item_name"`
  14. ItemType int64 `gorm:"column:item_type" json:"item_type"`
  15. }
  16. type defaultAds12Model struct {
  17. tableName string
  18. fields string
  19. }
  20. func NewAds12Model() Ads12Model {
  21. return &defaultAds12Model{
  22. tableName: "db_adm_ads.t_gd_maintain_item",
  23. fields: "id, item_id, item_name, item_type",
  24. }
  25. }
  26. func (d *defaultAds12Model) Get (db *gorm.DB) (*Ads12, error) {
  27. var res Ads12
  28. err := database.Get(db, &res, database.Option{
  29. TableName: d.tableName,
  30. Fields: d.fields,
  31. })
  32. return &res, err
  33. }
  34. func (d *defaultAds12Model) List (db *gorm.DB, fields string) ([]Ads12, error) {
  35. if fields == "" {
  36. fields = d.fields
  37. }
  38. var res []Ads12
  39. err := database.List(db, &res, database.Option{
  40. TableName: d.tableName,
  41. Fields: fields,
  42. })
  43. return res, err
  44. }