附近小店
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.1 KiB

2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
2 kuukautta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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=? and state=0", arg["store_type"])
  10. if arg["cid"] != "" {
  11. sess.And("cid=?", arg["cid"])
  12. }
  13. if arg["uid"] != "" {
  14. sess.And("uid=?", arg["uid"])
  15. }
  16. if arg["title"] != "" {
  17. sess.And("title like ?", "%"+arg["title"]+"%")
  18. }
  19. limit := utils.StrToInt(arg["size"])
  20. start := (utils.StrToInt(arg["p"]) - 1) * limit
  21. err := sess.OrderBy("sort desc,sale_count desc,id desc").Limit(limit, start).Find(&data)
  22. if err != nil {
  23. return nil
  24. }
  25. return &data
  26. }
  27. func GetGoodsSess(sess *xorm.Session, id int) *model.CommunityTeamGoods {
  28. var data model.CommunityTeamGoods
  29. get, err := sess.Where("id=?", id).Get(&data)
  30. if get == false || err != nil {
  31. return nil
  32. }
  33. return &data
  34. }
  35. func GetGoodsId(eg *xorm.Engine, id string) *model.CommunityTeamGoods {
  36. var data model.CommunityTeamGoods
  37. get, err := eg.Where("id=?", id).Get(&data)
  38. if get == false || err != nil {
  39. return nil
  40. }
  41. return &data
  42. }