附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_goods.go 1.0 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetGoods(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamGoods {
  8. var data []model.CommunityTeamGoods
  9. sess := eg.Where("store_type=0 and state=0")
  10. if arg["cid"] != "" {
  11. sess.And("cid=?", arg["cid"])
  12. }
  13. if arg["title"] != "" {
  14. sess.And("title like ?", "%"+arg["title"]+"%")
  15. }
  16. limit := utils.StrToInt(arg["size"])
  17. start := (utils.StrToInt(arg["p"]) - 1) * limit
  18. err := sess.OrderBy("sort desc,sale_count desc,id desc").Limit(limit, start).Find(&data)
  19. if err != nil {
  20. return nil
  21. }
  22. return &data
  23. }
  24. func GetGoodsSess(sess *xorm.Session, id int) *model.CommunityTeamGoods {
  25. var data model.CommunityTeamGoods
  26. get, err := sess.Where("id=?", id).Get(&data)
  27. if get == false || err != nil {
  28. return nil
  29. }
  30. return &data
  31. }
  32. func GetGoodsId(eg *xorm.Engine, id string) *model.CommunityTeamGoods {
  33. var data model.CommunityTeamGoods
  34. get, err := eg.Where("id=?", id).Get(&data)
  35. if get == false || err != nil {
  36. return nil
  37. }
  38. return &data
  39. }