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

46 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 GetOrderGoodsListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) {
  8. var order []model.OrderGoods
  9. sess := eg.Where("state!=5")
  10. if param["oid"] != "" {
  11. sess.And("oid = ?", param["oid"])
  12. }
  13. if param["state"] != "" {
  14. sess.And("state =?", param["state"])
  15. }
  16. if param["keyword"] != "" {
  17. sess.And("goods_title like ?", "%"+param["keyword"]+"%")
  18. }
  19. size := utils.StrToInt(param["limit"])
  20. start := (utils.StrToInt(param["page"]) - 1) * size
  21. count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order)
  22. if err != nil {
  23. return nil, count
  24. }
  25. return &order, count
  26. }
  27. func GetOrderGoodsById(eg *xorm.Engine, id string) *model.OrderGoods {
  28. var order model.OrderGoods
  29. get, err := eg.Where("id=?", id).Get(&order)
  30. if get == false || err != nil {
  31. return nil
  32. }
  33. return &order
  34. }
  35. func GetOrderGoodsByIdSess(sess *xorm.Session, id string) *model.OrderGoods {
  36. var order model.OrderGoods
  37. get, err := sess.Where("id=?", id).Get(&order)
  38. if get == false || err != nil {
  39. return nil
  40. }
  41. return &order
  42. }