From 0e3ac4cb775e118cb5165b591dfc5979f9361809 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 21 Aug 2023 13:35:31 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/etc/upload.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index a2a2cb4b..37f60999 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -2,6 +2,7 @@ Name: upload Host: 0.0.0.0 Port: 9912 Timeout: 150000 #服务超时时间 +MaxBytes: 8388608 #传输字节大小 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Env: "test" Auth: From 23d68effd45eb187c17f32bcec3b5496ff070936 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 21 Aug 2023 13:42:11 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/internal/logic/uploadlogologic.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index bd495c61..0318e245 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -95,6 +95,12 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image") } + // 限制上传文件大小 50k + maxSize := 100 * 1024 + if fileHeader.Size > int64(maxSize) { + return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,The file size exceeds the maximum limit of 100k") + } + // 读取数据流 ioData, err := io.ReadAll(fileObject) if err != nil { From 94d93bf39016f075310e76069aa9e5226ba75e4f Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 21 Aug 2023 14:06:24 +0800 Subject: [PATCH 3/4] fix --- server/resource/etc/resource.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 099a6460..f2f27737 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -15,8 +15,8 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: - # Url: "http://18.119.109.254:8999" - Url: "http://192.168.1.7:8999" + Url: "http://18.119.109.254:8999" + # Url: "http://192.168.1.7:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file From 5e251e9868aefe62c63aa3a2464ae8f4c48f3033 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 21 Aug 2023 14:39:03 +0800 Subject: [PATCH 4/4] fix --- server/upload/etc/upload.yaml | 2 +- service/repositories/image_handle.go | 35 ++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 37f60999..8f8afac9 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -2,7 +2,7 @@ Name: upload Host: 0.0.0.0 Port: 9912 Timeout: 150000 #服务超时时间 -MaxBytes: 8388608 #传输字节大小 +MaxBytes: 104857600 #传输字节大小 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Env: "test" Auth: diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index b5ff1763..305ffe2c 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -257,15 +257,46 @@ type ( IsmaxProportion bool ImgColor []string } + LogoStandardMetaData struct { + Param LogoStandardReq `json:"param"` + Result LogoStandardRes `json:"result"` + } ) /* 图片裁剪 */ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) { + var ismaxProportion bool + var imgColor []string + var logoStandardMetaData LogoStandardMetaData + var hashKeyDataMap map[string]interface{} hashKeyDataB, _ := json.Marshal(in) json.Unmarshal(hashKeyDataB, &hashKeyDataMap) var resourceId string = hash.JsonHashKey(hashKeyDataMap) + resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) + resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) + if err == nil && resourceInfo.ResourceId != "" { + if resourceInfo.Metadata != nil { + json.Unmarshal([]byte(*resourceInfo.Metadata), &logoStandardMetaData) + } + // 取出参数 + + return &LogoStandardRes{ + ResourceId: resourceInfo.ResourceId, + ResourceUrl: *resourceInfo.ResourceUrl, + IsmaxProportion: ismaxProportion, + ImgColor: imgColor, + }, nil + } else { + if err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error(err) + return nil, err + } + } + } + var postMap = make(map[string]interface{}, 5) postMap["is_remove_bg"] = in.IsRemoveBg postMap["logo_file"] = in.LogoFile @@ -319,12 +350,12 @@ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardR logx.Error(err) return nil, err } + //$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}' var fileBase = resultData["nobg_url"].(string) - var ismaxProportion = resultData["ismax_proportion"].(bool) + ismaxProportion = resultData["ismax_proportion"].(bool) - var imgColor []string for _, v := range resultData["img_color"].([]interface{}) { imgColor = append(imgColor, v.(string)) }