From 4a8b245ffda892cc089d11f9d92ceab27607e4da Mon Sep 17 00:00:00 2001 From: Hiven Date: Wed, 16 Aug 2023 16:08:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/image_handle.go | 47 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 861a9f1e..9ef14c26 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -46,7 +46,7 @@ type ( UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` TemplateId int64 `json:"template_id"` - TemplateTag string `json:"resource_key"` + TemplateTag string `json:"template_tag"` Website string `json:"website"` // 合图参数 Slogan string `json:"slogan"` // 合图参数 Address string `json:"address"` // 合图参数 @@ -61,8 +61,30 @@ type ( ) func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { + + // 查询logo最新基础信息 + var metadata *string + userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) + userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) + + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0) + if err != nil { + logx.Error(err) + return nil, err + } + metadata = userMaterialInfoDefault.Metadata + } else { + logx.Error(err) + return nil, err + } + } else { + metadata = userMaterialInfo.Metadata + } + // 根据hash 查询数据资源 - var resourceId string = hash.JsonHashKey(in) + var resourceId string = hash.JsonHashKey(userMaterialInfo.ResourceUrl) resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) @@ -116,27 +138,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["groupOptions"] = groupOptions moduleDataMap["materialList"] = materialList - // 查询logo最新基础信息 - var metadata *string - userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) - userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) - - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0) - if err != nil { - logx.Error(err) - return nil, err - } - metadata = userMaterialInfoDefault.Metadata - } else { - logx.Error(err) - return nil, err - } - } else { - metadata = userMaterialInfo.Metadata - } - var combineParam map[string]interface{} json.Unmarshal([]byte(*metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag