fix
This commit is contained in:
parent
c47927d192
commit
6a912a145e
|
@ -153,3 +153,17 @@ func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Co
|
||||||
err = db.Find(&resp).Error
|
err = db.Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
func (t *FsProductTemplateV2Model) FindAllByProductIdsTemplateTag(ctx context.Context, productIds []int64, templateTag string, sort string, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||||
|
if len(productIds) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `template_tag` = ? and `is_del` = ? and `status` = ?", productIds, templateTag, 0, 1)
|
||||||
|
if sort != "" {
|
||||||
|
db = db.Order(sort)
|
||||||
|
}
|
||||||
|
if len(fields) != 0 {
|
||||||
|
db = db.Select(fields[0])
|
||||||
|
}
|
||||||
|
err = db.Find(&resp).Error
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
|
@ -170,13 +170,20 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取模板(只是获取产品product_id,id)
|
//获取模板(只是获取产品product_id,id)
|
||||||
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id,id")
|
if req.TemplateTag != "" { //指定模板tag
|
||||||
|
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIdsTemplateTag(l.ctx, productIds, req.TemplateTag, "sort ASC", "product_id,id")
|
||||||
|
} else { //没指定模板tag
|
||||||
|
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id,id")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product templates")
|
||||||
}
|
}
|
||||||
//只存第一个
|
//只存第一个
|
||||||
for _, v := range productTemplatesV2 {
|
for _, v := range productTemplatesV2 {
|
||||||
|
if _, ok := mapProductTemplate[*v.ProductId]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
mapProductTemplate[*v.ProductId] = v.Id
|
mapProductTemplate[*v.ProductId] = v.Id
|
||||||
}
|
}
|
||||||
//获取产品尺寸数量
|
//获取产品尺寸数量
|
||||||
|
|
|
@ -249,6 +249,7 @@ type GetRecommandProductListRsp struct {
|
||||||
type GetTagProductListReq struct {
|
type GetTagProductListReq struct {
|
||||||
Cid int64 `form:"cid,optional"` //分类id
|
Cid int64 `form:"cid,optional"` //分类id
|
||||||
Size uint32 `form:"size,optional"` //尺寸
|
Size uint32 `form:"size,optional"` //尺寸
|
||||||
|
TemplateTag string `form:"template_tag,optional"` //模板标签
|
||||||
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,6 +301,7 @@ type GetRecommandProductListRsp {
|
||||||
type GetTagProductListReq {
|
type GetTagProductListReq {
|
||||||
Cid int64 `form:"cid,optional"` //分类id
|
Cid int64 `form:"cid,optional"` //分类id
|
||||||
Size uint32 `form:"size,optional"` //尺寸
|
Size uint32 `form:"size,optional"` //尺寸
|
||||||
|
TemplateTag string `form:"template_tag,optional"` //模板标签
|
||||||
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
||||||
}
|
}
|
||||||
type GetTagProductListRsp {
|
type GetTagProductListRsp {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user