|
123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- func GetOrderGoodsListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) {
- var order []model.OrderGoods
- sess := eg.Where("state!=5")
-
- if param["oid"] != "" {
- sess.And("oid = ?", param["oid"])
- }
- if param["state"] != "" {
- sess.And("state =?", param["state"])
- }
- if param["keyword"] != "" {
- sess.And("goods_title like ?", "%"+param["keyword"]+"%")
- }
- size := utils.StrToInt(param["limit"])
- start := (utils.StrToInt(param["page"]) - 1) * size
- count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order)
- if err != nil {
- return nil, count
- }
- return &order, count
- }
- func GetOrderGoodsById(eg *xorm.Engine, id string) *model.OrderGoods {
- var order model.OrderGoods
- get, err := eg.Where("id=?", id).Get(&order)
- if get == false || err != nil {
- return nil
- }
- return &order
- }
- func GetOrderGoodsByIdSess(sess *xorm.Session, id string) *model.OrderGoods {
- var order model.OrderGoods
- get, err := sess.Where("id=?", id).Get(&order)
- if get == false || err != nil {
- return nil
- }
- return &order
- }
|