From 414a3f8507615cc5758411b712283830fb99ae34 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Sun, 8 Oct 2023 10:22:00 +0800 Subject: [PATCH] fix --- .../internal/logic/gettemplatetagcolorlogic.go | 12 +++++------- service/repositories/image_handle.go | 9 ++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/server/product-template-tag/internal/logic/gettemplatetagcolorlogic.go b/server/product-template-tag/internal/logic/gettemplatetagcolorlogic.go index a9030f97..89f0b9fc 100644 --- a/server/product-template-tag/internal/logic/gettemplatetagcolorlogic.go +++ b/server/product-template-tag/internal/logic/gettemplatetagcolorlogic.go @@ -1,15 +1,14 @@ package logic import ( + "context" "encoding/json" "errors" "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" + "fusenapi/utils/s3url_to_s3id" "gorm.io/gorm" - "strings" - - "context" "fusenapi/server/product-template-tag/internal/svc" "fusenapi/server/product-template-tag/internal/types" @@ -40,11 +39,10 @@ func (l *GetTemplateTagColorLogic) GetTemplateTagColor(req *types.GetTemplateTag return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "param selected_color_index is invalid") } //根据logo查询素材资源 - s := strings.Split(req.Logo, "/") - if len(s) <= 1 { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid logo") + resourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo) + if resourceId == "" { + return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "param logo is invalid") } - resourceId := s[len(s)-1] var ( userMaterial *gmodel.FsUserMaterial templateTagInfo *gmodel.FsProductTemplateTags diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 19a2c8c6..9090e0ab 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -9,7 +9,7 @@ import ( "fusenapi/utils/curl" "fusenapi/utils/file" "fusenapi/utils/hash" - "strings" + "fusenapi/utils/s3url_to_s3id" "time" "github.com/aws/aws-sdk-go/aws/session" @@ -225,11 +225,10 @@ type TemplateTagColor struct { } func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { - s := strings.Split(in.LogoUrl, "/") - if len(s) <= 1 { - return nil, errors.New("无效的logo") + logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(in.LogoUrl) + if logoResourceId == "" { + return nil, errors.New("invalid logo url") } - logoResourceId := s[len(s)-1] userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) resLogoInfo, err := userMaterialModel.FindOneByLogoResourceId(ctx, logoResourceId) if err != nil {