From 0aef122f1b1bdb95b6610fbbe005dfde271a79f9 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 12 Sep 2023 18:09:38 +0800 Subject: [PATCH] 11 --- server/product/internal/logic/getsizebypidlogic.go | 7 ++----- server/product/internal/types/types.go | 1 + server_api/product.api | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/product/internal/logic/getsizebypidlogic.go b/server/product/internal/logic/getsizebypidlogic.go index 3ab04044..0515f61e 100644 --- a/server/product/internal/logic/getsizebypidlogic.go +++ b/server/product/internal/logic/getsizebypidlogic.go @@ -73,13 +73,9 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a } sizeIds := make([]int64, 0, len(sizeList)) productIds := make([]int64, 0, len(sizeList)) - for k, v := range sizeList { + for _, v := range sizeList { sizeIds = append(sizeIds, v.Id) productIds = append(productIds, *v.ProductId) - //把默认的排第一 - if v.Id == defaultSizeId { - sizeList[0], sizeList[k] = sizeList[k], sizeList[0] - } } //获取产品价格列表 productPriceList, err := l.svcCtx.AllModels.FsProductPrice.GetSimplePriceListByProductIds(l.ctx, productIds) @@ -142,6 +138,7 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a ModelId: modelList[modelIndex].Id, IsPopular: *sizeInfo.IsHot > 0, MinPrice: float64(minPrice) / 100, + IsDefault: defaultSizeId == sizeInfo.Id, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 4ce8f513..2de27f35 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -345,6 +345,7 @@ type GetSizeByPidRsp struct { ModelId int64 `json:"model_id"` //产品主模型id IsPopular bool `json:"is_popular"` //是否受欢迎 MinPrice float64 `json:"min_price"` //最小价格 + IsDefault bool `json:"is_default"` //是否默认(这里的默认是跟列表页一致) } type GetTemplateByPidReq struct { diff --git a/server_api/product.api b/server_api/product.api index 9602fea9..95346d07 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -390,6 +390,7 @@ type GetSizeByPidRsp { ModelId int64 `json:"model_id"` //产品主模型id IsPopular bool `json:"is_popular"` //是否受欢迎 MinPrice float64 `json:"min_price"` //最小价格 + IsDefault bool `json:"is_default"` //是否默认(这里的默认是跟列表页一致) } //获取产品模板 type GetTemplateByPidReq {