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) var metadataChildUserInfo = make(map[string]interface{}, 1)
_, userInfoLogoSelectedEx := metadataMapOldUserInfo["logo_selected"] userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"]
if !userInfoLogoSelectedEx { if !userMaterialTemplateTagEx {
userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"] logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err%+v", err)
if !userMaterialTemplateTagEx { return err
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err%+v", err) }
return err userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"]
} if !userMaterialTemplateTagIdEx {
userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"] logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err%+v", err)
if !userMaterialTemplateTagIdEx { return err
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err%+v", err) }
return err userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{})
}
userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{})
userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string) userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string)
userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{}) userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{})
userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId] userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId]
templateTagSelected := make(map[string]interface{}, 3) templateTagSelected := make(map[string]interface{}, 3)
templateTagSelected["color"] = userMaterialTemplateTagIndex templateTagSelected["color"] = userMaterialTemplateTagIndex
templateTagSelected["template_tag"] = userMaterialTemplateIdTagId templateTagSelected["template_tag"] = userMaterialTemplateIdTagId
templateTagSelected["selected_index"] = 0 templateTagSelected["selected_index"] = 0
metadataChildUserInfo["logo_selected"] = map[string]interface{}{ metadataChildUserInfo["logo_selected"] = map[string]interface{}{
"logo_selected_id": req.LogoSelectedId, "logo_selected_id": req.LogoSelectedId,
"template_tag_selected": templateTagSelected, "template_tag_selected": templateTagSelected,
}
} else {
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
"logo_selected_id": req.LogoSelectedId,
}
} }
metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo) 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"` LogoSelectedId int64 `json:"logo_selected_id"`
} `json:"logo_selected"` } `json:"logo_selected"`
} }
userInfo.Id = 0
if userInfo.Id == 0 { if userInfo.Id == 0 {
userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) 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) logc.Errorf(ctx, "FsUserMaterial FindLatestOne err%+v", err)
return nil, err return nil, err
} }
// var userMaterialInfoMetadata map[string]interface{}
} else { } else {
if userInfo.Metadata != nil { if userInfo.Metadata != nil {
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo) err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo)
@ -150,9 +150,8 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
logoUrl = userMaterialInfo.ResourceUrl logoUrl = userMaterialInfo.ResourceUrl
} }
return &LogoInfoRes{ return &LogoInfoRes{
Metadata: metadata, Metadata: metadata,
LogoUrl: logoUrl, LogoUrl: logoUrl,
LogoSelected: metadataUserInfo.LogoSelected,
}, nil }, nil
} }