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

43 lines
1.1 KiB

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