|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- func GetOrderEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrder {
- var data model.CommunityTeamOrder
- get, err := eg.Where("oid=?", oid).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
- func GetOrder(sess *xorm.Session, oid string) *model.CommunityTeamOrder {
- var data model.CommunityTeamOrder
- get, err := sess.Where("oid=?", oid).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
- func GetOrderInfo(sess *xorm.Session, oid string) *[]model.CommunityTeamOrderInfo {
- var data []model.CommunityTeamOrderInfo
- err := sess.Where("oid=?", oid).Find(&data)
- if err != nil {
- return nil
- }
- return &data
- }
- func GetOrderInfoAllEg(eg *xorm.Engine, oid string) *[]model.CommunityTeamOrderInfo {
- var data []model.CommunityTeamOrderInfo
- err := eg.Where("oid=?", oid).Find(&data)
- if err != nil {
- return nil
- }
- return &data
- }
- func GetOrderInfoEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrderInfo {
- var data model.CommunityTeamOrderInfo
- get, err := eg.Where("oid=?", oid).Asc("id").Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
-
- func GetOrderList(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamOrder {
- var data []model.CommunityTeamOrder
- sess := eg.Where("1=1")
- if arg["uid"] != "" {
- sess.And("uid=?", arg["uid"])
- }
- if arg["state"] != "" {
- sess.And("state=?", arg["state"])
- }
- if arg["store_uid"] != "" {
- sess.And("store_uid=?", arg["store_uid"])
- }
- if arg["code"] != "" {
- sess.And("code=?", arg["code"])
- }
- limit := utils.StrToInt(arg["size"])
- start := (utils.StrToInt(arg["p"]) - 1) * limit
- err := sess.OrderBy("id desc").Limit(limit, start).Find(&data)
- if err != nil {
- return nil
- }
- return &data
- }
|