附近小店
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
746 B

  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. limit := utils.StrToInt(arg["size"])
  14. start := (utils.StrToInt(arg["p"]) - 1) * limit
  15. err := sess.OrderBy("sale_count desc,id desc").Limit(limit, start).Find(&data)
  16. if err != nil {
  17. return nil
  18. }
  19. return &data
  20. }
  21. func GetGoodsSess(sess *xorm.Session, id int) *model.CommunityTeamGoods {
  22. var data model.CommunityTeamGoods
  23. get, err := sess.Where("id=?", id).Get(&data)
  24. if get == false || err != nil {
  25. return nil
  26. }
  27. return &data
  28. }