diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index d97c768a..7191f110 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -6,7 +6,6 @@ import ( "fusenapi/model/gmodel" "fusenapi/server/product-template-tag/internal/svc" "fusenapi/server/product-template-tag/internal/types" - "fusenapi/service/repositories" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/s3url_to_s3id" @@ -55,16 +54,17 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu productTemplateTags []gmodel.FsProductTemplateTags err error ) - //获取用户需要渲染logo - logoInfo, err := l.svcCtx.Repositories.ImageHandle.LogoInfo(l.ctx, &repositories.LogoInfoReq{ - UserId: userinfo.UserId, - GuestId: userinfo.GuestId, - }) + if req.Logo == "" { + return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "logo is required") + } + logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo) + logoInfo, err := l.svcCtx.AllModels.FsUserMaterial.FindOneByLogoResourceId(l.ctx, logoResourceId) if err != nil { logx.Error(err) - return + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get logo info") } - if logoInfo.Metadata == nil || *logoInfo.Metadata == "" { + //查询logo素材信息 + if logoInfo.Metadata == nil || len(*logoInfo.Metadata) == 0 { return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "logo info`s metadata is not set") } //解析用户素材元数据 @@ -89,18 +89,16 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu } //从用户元数据获取选中的颜色数据 mapSelectColor := make(map[string]int) //key是模板标签val是选中的索引 - if logoInfo.UserInfoMetadata != nil && *logoInfo.UserInfoMetadata != "" { - //解析用户信息元数据 - var logoSelectInfo LogoSelect - if err = json.Unmarshal([]byte(*logoInfo.UserInfoMetadata), &logoSelectInfo); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata") - } - //设置选中 - key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag - if _, ok := mapMaterialTemplateTagColors[key]; ok { - mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex - } + //解析用户信息元数据 + var logoSelectInfo LogoSelect + if err = json.Unmarshal(*logoInfo.Metadata, &logoSelectInfo); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata") + } + //设置选中 + key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag + if _, ok := mapMaterialTemplateTagColors[key]; ok { + mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex } var templateTagNameList []string for templateTag, _ := range mapMaterialTemplateTagColors { diff --git a/server/product-template-tag/internal/types/types.go b/server/product-template-tag/internal/types/types.go index 0a83336c..21280e74 100644 --- a/server/product-template-tag/internal/types/types.go +++ b/server/product-template-tag/internal/types/types.go @@ -6,7 +6,8 @@ import ( ) type GetProductTemplateTagsReq struct { - Limit int `form:"limit"` + Limit int `form:"limit"` + Logo string `form:"logo"` } type GetProductTemplateTagsRsp struct { diff --git a/server_api/product-template-tag.api b/server_api/product-template-tag.api index c424cd91..d550070b 100644 --- a/server_api/product-template-tag.api +++ b/server_api/product-template-tag.api @@ -20,7 +20,8 @@ service product-template-tag { //获取产品模板标签列表 type GetProductTemplateTagsReq { - Limit int `form:"limit"` + Limit int `form:"limit"` + Logo string `form:"logo"` } type GetProductTemplateTagsRsp { Id int64 `json:"id"`