fix:合图调整

This commit is contained in:
momo 2023-09-19 14:50:54 +08:00
parent dbb1591cbb
commit 640560acf6
2 changed files with 25 additions and 33 deletions

View File

@ -137,38 +137,31 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
var metadataChildUserInfo = make(map[string]interface{}, 1)
_, userInfoLogoSelectedEx := metadataMapOldUserInfo["logo_selected"]
if !userInfoLogoSelectedEx {
userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"]
if !userMaterialTemplateTagEx {
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err%+v", err)
return err
}
userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"]
if !userMaterialTemplateTagIdEx {
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err%+v", err)
return err
}
userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{})
userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"]
if !userMaterialTemplateTagEx {
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err%+v", err)
return err
}
userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"]
if !userMaterialTemplateTagIdEx {
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err%+v", err)
return err
}
userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{})
userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string)
userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string)
userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{})
userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId]
userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{})
userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId]
templateTagSelected := make(map[string]interface{}, 3)
templateTagSelected["color"] = userMaterialTemplateTagIndex
templateTagSelected["template_tag"] = userMaterialTemplateIdTagId
templateTagSelected["selected_index"] = 0
templateTagSelected := make(map[string]interface{}, 3)
templateTagSelected["color"] = userMaterialTemplateTagIndex
templateTagSelected["template_tag"] = userMaterialTemplateIdTagId
templateTagSelected["selected_index"] = 0
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
"logo_selected_id": req.LogoSelectedId,
"template_tag_selected": templateTagSelected,
}
} else {
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
"logo_selected_id": req.LogoSelectedId,
}
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
"logo_selected_id": req.LogoSelectedId,
"template_tag_selected": templateTagSelected,
}
metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo)

View File

@ -102,13 +102,13 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
LogoSelectedId int64 `json:"logo_selected_id"`
} `json:"logo_selected"`
}
userInfo.Id = 0
if userInfo.Id == 0 {
userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
if err != gorm.ErrRecordNotFound {
if err != nil && err != gorm.ErrRecordNotFound {
logc.Errorf(ctx, "FsUserMaterial FindLatestOne err%+v", err)
return nil, err
}
// var userMaterialInfoMetadata map[string]interface{}
} else {
if userInfo.Metadata != nil {
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo)
@ -150,9 +150,8 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
logoUrl = userMaterialInfo.ResourceUrl
}
return &LogoInfoRes{
Metadata: metadata,
LogoUrl: logoUrl,
LogoSelected: metadataUserInfo.LogoSelected,
Metadata: metadata,
LogoUrl: logoUrl,
}, nil
}