From 98b0765363d547eec4c24798fd0c0ba5c5db6125 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 14:51:54 +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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index f683df49..d751b8af 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -117,16 +117,28 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["materialList"] = materialList // 查询logo最新基础信息 + var metadata *string userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) if err != nil { - logx.Error(err) - return nil, err + 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(*userMaterialInfo.Metadata), &combineParam) + json.Unmarshal([]byte(*metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag combineParam["website"] = in.Website combineParam["slogan"] = in.Slogan