From a646f6700a75ec65957f995dc0c9eb87b55602e1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 12 Sep 2024 15:39:17 +0800 Subject: [PATCH] 1 --- app/db/db_goods.go | 13 ++++++++++++- app/svc/svc_goods.go | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/db/db_goods.go b/app/db/db_goods.go index 42e151f..04b450f 100644 --- a/app/db/db_goods.go +++ b/app/db/db_goods.go @@ -12,9 +12,12 @@ func GetGoods(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamGood if arg["cid"] != "" { sess.And("cid=?", arg["cid"]) } + if arg["title"] != "" { + sess.And("title like ?", "%"+arg["title"]+"%") + } 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) + err := sess.OrderBy("sort desc,sale_count desc,id desc").Limit(limit, start).Find(&data) if err != nil { return nil } @@ -29,3 +32,11 @@ func GetGoodsSess(sess *xorm.Session, id int) *model.CommunityTeamGoods { } return &data } +func GetGoodsId(eg *xorm.Engine, id string) *model.CommunityTeamGoods { + var data model.CommunityTeamGoods + get, err := eg.Where("id=?", id).Get(&data) + if get == false || err != nil { + return nil + } + return &data +} diff --git a/app/svc/svc_goods.go b/app/svc/svc_goods.go index 326088a..adf5923 100644 --- a/app/svc/svc_goods.go +++ b/app/svc/svc_goods.go @@ -59,7 +59,12 @@ func GoodsSku(c *gin.Context) { skuList = append(skuList, tmp) } } - e.OutSuc(c, skuList, nil) + goods := db.GetGoodsId(MasterDb(c), arg["goods_id"]) + res := map[string]interface{}{ + "spe": goods.Spe, + "sku_list": skuList, + } + e.OutSuc(c, res, nil) return } func GoodsCoupon(c *gin.Context) {