feat:合图调整
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user