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

3 months ago
12345678910111213141516171819202122232425262728293031
  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. }