edbdata_classify.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type EdbdataClassify struct {
  7. ClassifyId int `orm:"column(classify_id);pk"`
  8. ClassifyName string
  9. ParentId int
  10. CreateTime time.Time
  11. Sort int
  12. }
  13. func GetEdbdataClassifyByClassifyName(classifyName string) (item *EdbdataClassify, err error) {
  14. sql := `SELECT * FROM edbdata_classify WHERE classify_name=? `
  15. o := orm.NewOrmUsingDB("edb")
  16. err = o.Raw(sql, classifyName).QueryRow(&item)
  17. return
  18. }
  19. func AddEdbdataClassify(item *EdbdataClassify) (newId int64, err error) {
  20. o := orm.NewOrmUsingDB("edb")
  21. newId, err = o.Insert(item)
  22. return
  23. }
  24. func GetEdbdataClassifyByParentId(parentId int) (items []*EdbdataClassify, err error) {
  25. sql := ` SELECT * FROM edbdata_classify WHERE parent_id=? `
  26. o := orm.NewOrmUsingDB("edb")
  27. o.Raw(sql, parentId).QueryRows(&items)
  28. return
  29. }
  30. type LzPriceClassify struct {
  31. ProductName string
  32. }
  33. func GetLzPriceClassify() (items []*LzPriceClassify, err error) {
  34. sql := ` SELECT product_name FROM longzhongpriceinfo GROUP BY product_name ORDER BY product_name DESC `
  35. o := orm.NewOrmUsingDB("edb")
  36. o.Raw(sql).QueryRows(&items)
  37. return
  38. }