This commit is contained in:
laodaming 2023-10-24 10:19:42 +08:00
parent 9f12f7035c
commit ffd371d54c
3 changed files with 17 additions and 1 deletions

View File

@ -120,11 +120,21 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
}
//获取默认渲染的产品(写死)
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOne(l.ctx, 30)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the product info is not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
}
//资源id集合
resourceIds := make([]string, 0, 5)
for _, v := range productTemplateTags {
resourceIds = append(resourceIds, s3url_to_s3id.GetS3ResourceIdFormUrl(*v.Cover))
}
resourceIds = append(resourceIds, s3url_to_s3id.GetS3ResourceIdFormUrl(*productInfo.Cover))
//根据resourceUrls找到对应的元数据
resourceMetadataList, err := l.svcCtx.AllModels.FsResource.FindAllByResourceIds(l.ctx, resourceIds)
if err != nil {
@ -180,7 +190,9 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
CoverMetadata: mapResourceMetadata[*templateTagInfo.Cover],
Colors: colors,
SelectedColorIndex: SelectedColorIndex,
ProductId: 30,
ProductId: productInfo.Id,
ProductCover: *productInfo.Cover,
ProductCoverMetadata: mapResourceMetadata[*productInfo.Cover],
})
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)

View File

@ -20,6 +20,8 @@ type GetProductTemplateTagsRsp struct {
Colors [][]string `json:"colors"`
SelectedColorIndex int `json:"selected_color_index"`
ProductId int64 `json:"product_id"`
ProductCover string `json:"product_cover"`
ProductCoverMetadata interface{} `json:"product_cover_metadata"`
}
type GetTemplateTagColorReq struct {

View File

@ -33,6 +33,8 @@ type GetProductTemplateTagsRsp {
Colors [][]string `json:"colors"`
SelectedColorIndex int `json:"selected_color_index"`
ProductId int64 `json:"product_id"`
ProductCover string `json:"product_cover"`
ProductCoverMetadata interface{} `json:"product_cover_metadata"`
}
//根据模板标签跟logo还有选择颜色的索引获取颜色
type GetTemplateTagColorReq {