feat:合图调整

This commit is contained in:
momo
2023-08-31 11:56:15 +08:00
parent 2853d8599f
commit ad7a8858a2
5 changed files with 165 additions and 4 deletions

View File

@@ -18,8 +18,8 @@ AWS:
Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm
Token:
BLMService:
Url: "http://18.119.109.254:8999"
# Url: "http://192.168.1.9:8999"
# Url: "http://18.119.109.254:8999"
Url: "http://192.168.1.9:8999"
LogoCombine:
#Url: "http://192.168.1.7:8999/LogoCombine"
Url: "http://18.119.109.254:8999/LogoCombine"

View File

@@ -3,7 +3,9 @@ package logic
import (
"bytes"
"encoding/json"
"fmt"
"fusenapi/model/gmodel"
"fusenapi/service/repositories"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/file"
@@ -96,6 +98,7 @@ func (l *LogoResizeLogic) LogoResize(req *types.LogoResizeReq, userinfo *auth.Us
hashKeyDataB, _ := json.Marshal(req)
json.Unmarshal(hashKeyDataB, &hashKeyDataMap)
var resourceId string = hash.JsonHashKey(hashKeyDataMap)
fmt.Println(resourceId)
// 上传文件
var upload = file.Upload{
@@ -116,10 +119,28 @@ func (l *LogoResizeLogic) LogoResize(req *types.LogoResizeReq, userinfo *auth.Us
logx.Errorf("upload UploadFileByByte err: %v", err)
return resp.SetStatus(basic.CodeFileNoFoundErr)
}
metadataChild := make(map[string]interface{}, 1)
metadataChildData := make(map[string]interface{}, 1)
metadataChildKey := fmt.Sprintf("%d*%d", req.Width, req.Height)
metadataChildData[metadataChildKey] = repositories.Cropping{
ResourceId: uploadRes.ResourceId,
ResourceUrl: uploadRes.ResourceUrl,
Width: req.Width,
Height: req.Height,
}
metadataChild["cropping"] = metadataChildData
// 原图metadata 更新
_, err = l.svcCtx.Repositories.NewResource.UpdateMetadata(l.ctx, &repositories.UpdateMetadataReq{
ResourceId: req.ResourceId,
MetadataChild: metadataChild,
})
// 返回成功的响应和上传URL
if err != nil {
return resp.SetStatus(basic.CodeServiceErr, "原图metadata更新失败")
}
// 返回成功的响应
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"resource_id": uploadRes.ResourceId,
"resource_url": uploadRes.ResourceUrl,