附近小店
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

db_good.go 1.3 KiB

il y a 2 mois
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetStoreGoods(eg *xorm.Engine, req map[string]string) (*[]model.CommunityTeamGoods, int64) {
  8. var data []model.CommunityTeamGoods
  9. limit := utils.StrToInt(req["size"])
  10. start := (utils.StrToInt(req["p"]) - 1) * limit
  11. sess := eg.Where("uid=?", req["uid"]).OrderBy("sort desc,id desc").Limit(limit, start)
  12. if req["title"] != "" {
  13. sess.And("title like ?", "%"+req["title"]+"%")
  14. }
  15. if req["cid"] != "" {
  16. sess.And("cid=?", req["cid"])
  17. }
  18. if req["store_type"] != "" {
  19. sess.And("store_type=?", req["store_type"])
  20. }
  21. if req["start_time"] != "" {
  22. sess.And("create_at>=?", req["start_time"])
  23. }
  24. if req["end_time"] != "" {
  25. sess.And("create_at<=?", req["end_time"])
  26. }
  27. count, err := sess.FindAndCount(&data)
  28. if err != nil {
  29. return nil, count
  30. }
  31. return &data, count
  32. }
  33. func GetGoodsById(eg *xorm.Engine, id string) *model.CommunityTeamGoods {
  34. var data model.CommunityTeamGoods
  35. get, err := eg.Where("id=?", id).Get(&data)
  36. if get == false || err != nil {
  37. return nil
  38. }
  39. return &data
  40. }
  41. func GetGoodsByIdSess(sess *xorm.Session, id string) *model.CommunityTeamGoods {
  42. var data model.CommunityTeamGoods
  43. get, err := sess.Where("id=?", id).Get(&data)
  44. if get == false || err != nil {
  45. return nil
  46. }
  47. return &data
  48. }