From 79eca4ef507f418b88a0817f43a9ea25750a818a Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 23 九月 2023 16:57:57 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- controllers/product_controller.go | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/controllers/product_controller.go b/controllers/product_controller.go index ca6f24e..15878dc 100644 --- a/controllers/product_controller.go +++ b/controllers/product_controller.go @@ -82,6 +82,22 @@ return } + ids := make([]int, 0) + for _, product := range products { + ids = append(ids, product.CategoryId) + } + categories, err := models.NewProductCategorySearch().SetIds(ids).FindNotTotal() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "浜у搧绫诲瀷鏌ユ壘澶辫触") + return + } + for _, product := range products { + for _, category := range categories { + if product.CategoryId == int(category.ID) { + product.CategoryName = category.Name + } + } + } util.ResponseFormatList(c, code.Success, products, int(total)) } -- Gitblit v1.8.0