=fix:修复

This commit is contained in:
Hiven 2023-08-08 14:55:17 +08:00
parent ff86cceb17
commit 1887b6e7b6
5 changed files with 37 additions and 55 deletions

View File

@ -15,4 +15,4 @@ AWS:
Token:
BLMService:
ImageProcess:
Url: "http://110.41.19.98:8868/removebg"
Url: "http://192.168.1.8:45678/FeatureExtraction"

View File

@ -50,18 +50,20 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
var guestId int64
// 检查用户是否是游客
if userinfo.IsGuest() {
// 如果是使用游客ID和游客键名格式
guestId = userinfo.GuestId
} else {
// 否则使用用户ID和用户键名格式
userId = userinfo.UserId
}
if guestId == 0 {
guestId = req.GuestId
}
if userId == 0 {
userId = req.UserId
if userinfo != nil {
if userinfo.IsGuest() {
// 如果是使用游客ID和游客键名格式
guestId = userinfo.GuestId
} else {
// 否则使用用户ID和用户键名格式
userId = userinfo.UserId
}
if guestId == 0 {
guestId = req.GuestId
}
if userId == 0 {
userId = req.UserId
}
}
// 定义存储桶名称

View File

@ -1,9 +1,13 @@
package logic
import (
"encoding/json"
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"io"
"net/http"
"strings"
"time"
"context"
@ -79,47 +83,23 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
}
var resultStr string
var err error
var postMap = make(map[string]interface{}, 1)
postMap["logo_url"] = req.ResourceUrl
postMapB, _ := json.Marshal(postMap)
// apiUrl := l.svcCtx.Config.BLMService.ImageProcess.Url
// var onlyScale = true
// data := url.Values{}
// data.Set("imgurl", req.ResourceUrl)
// data.Set("layerwidth", strconv.Itoa(int(logoWidth)))
// data.Set("layerheight", strconv.Itoa(int(logoHeight)))
// data.Set("is_remove_bg", strconv.Itoa(int(req.IsRemoveBg)))
// data.Set("proportion", strconv.Itoa(int(req.Proportion)))
// data.Set("only_scale", fmt.Sprintf("%v", onlyScale))
// u, err := url.ParseRequestURI(apiUrl)
// if err != nil {
// logx.Error(err)
// return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
// }
// u.RawQuery = data.Encode() // URL encode
// fmt.Println(u.String())
// result, err := http.Get(u.String())
// if err != nil {
// logx.Error(err)
// return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
// }
// defer result.Body.Close()
// b, err := io.ReadAll(result.Body)
// if err != nil {
// logx.Error(err)
// return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
// }
// resultStr = string(b)
// // 上传图片
// var reqs types.UploadFileBaseReq
// reqs.ApiType = 2
// reqs.UploadBucket = 2
// reqs.Metadata = ""
// reqs.FileData = ""
// reqs.FileKey = ""
// // 创建一个业务逻辑层实例
// resUpload := NewUploadFileBaseLogic(l.ctx, l.svcCtx).UploadFileBase(&reqs, userinfo)
contentType := "application/json"
result, err := http.Post(l.svcCtx.Config.BLMService.ImageProcess.Url, contentType, strings.NewReader(string(postMapB)))
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
}
defer result.Body.Close()
b, err := io.ReadAll(result.Body)
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
}
resultStr = string(b)
var module = "logo"
var nowTime = time.Now().Unix()

View File

@ -18,7 +18,7 @@ type UploadFileBaseReq struct {
type UploadLogoReq struct {
ResourceId string `form:"resource_id"` // 资源ID
ResourceUrl string `form:"resource_url"` // 资源URL
IsRemoveBg int64 `form:"is_remove_bg"` // 是否要去掉背景
IsRemoveBg int64 `form:"is_remove_bg,optional"` // 是否要去掉背景
Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例
SkuId int64 `form:"sku_id,default=0"` // 模板ID
}

View File

@ -60,7 +60,7 @@ type (
UploadLogoReq {
ResourceId string `form:"resource_id"` // 资源ID
ResourceUrl string `form:"resource_url"` // 资源URL
IsRemoveBg int64 `form:"is_remove_bg"` // 是否要去掉背景
IsRemoveBg int64 `form:"is_remove_bg,optional"` // 是否要去掉背景
Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例
SkuId int64 `form:"sku_id,default=0"` // 模板ID
}