This commit is contained in:
laodaming 2023-10-13 18:17:31 +08:00
parent dbffda69fd
commit 23b2eded5a
3 changed files with 22 additions and 22 deletions

View File

@ -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 {

View File

@ -6,7 +6,8 @@ import (
)
type GetProductTemplateTagsReq struct {
Limit int `form:"limit"`
Limit int `form:"limit"`
Logo string `form:"logo"`
}
type GetProductTemplateTagsRsp struct {

View File

@ -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"`