package db import ( "applet/app/db/model" "applet/app/utils" "xorm.io/xorm" ) func GetGoods(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamGoods { var data []model.CommunityTeamGoods sess := eg.Where("store_type=0 and state=0") if arg["cid"] != "" { sess.And("cid=?", arg["cid"]) } limit := utils.StrToInt(arg["size"]) start := (utils.StrToInt(arg["p"]) - 1) * limit err := sess.OrderBy("sale_count desc,id desc").Limit(limit, start).Find(&data) if err != nil { return nil } return &data } func GetGoodsSess(sess *xorm.Session, id int) *model.CommunityTeamGoods { var data model.CommunityTeamGoods get, err := sess.Where("id=?", id).Get(&data) if get == false || err != nil { return nil } return &data }