=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: Token:
BLMService: BLMService:
ImageProcess: ImageProcess:
Url: "http://110.41.19.98:8868/removebg" Url: "http://192.168.1.8:45678/FeatureExtraction"

View File

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

View File

@ -1,9 +1,13 @@
package logic package logic
import ( import (
"encoding/json"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/basic" "fusenapi/utils/basic"
"io"
"net/http"
"strings"
"time" "time"
"context" "context"
@ -79,47 +83,23 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
} }
var resultStr string var resultStr string
var err error 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 contentType := "application/json"
// var onlyScale = true result, err := http.Post(l.svcCtx.Config.BLMService.ImageProcess.Url, contentType, strings.NewReader(string(postMapB)))
// data := url.Values{} if err != nil {
// data.Set("imgurl", req.ResourceUrl) logx.Error(err)
// data.Set("layerwidth", strconv.Itoa(int(logoWidth))) return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
// data.Set("layerheight", strconv.Itoa(int(logoHeight))) }
// data.Set("is_remove_bg", strconv.Itoa(int(req.IsRemoveBg))) defer result.Body.Close()
// data.Set("proportion", strconv.Itoa(int(req.Proportion))) b, err := io.ReadAll(result.Body)
// data.Set("only_scale", fmt.Sprintf("%v", onlyScale)) if err != nil {
logx.Error(err)
// u, err := url.ParseRequestURI(apiUrl) return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
// if err != nil { }
// logx.Error(err) resultStr = string(b)
// 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)
var module = "logo" var module = "logo"
var nowTime = time.Now().Unix() var nowTime = time.Now().Unix()

View File

@ -18,7 +18,7 @@ type UploadFileBaseReq struct {
type UploadLogoReq struct { type UploadLogoReq struct {
ResourceId string `form:"resource_id"` // 资源ID ResourceId string `form:"resource_id"` // 资源ID
ResourceUrl string `form:"resource_url"` // 资源URL 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"` // 贴图在模型面板上的比例 Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例
SkuId int64 `form:"sku_id,default=0"` // 模板ID SkuId int64 `form:"sku_id,default=0"` // 模板ID
} }

View File

@ -60,7 +60,7 @@ type (
UploadLogoReq { UploadLogoReq {
ResourceId string `form:"resource_id"` // 资源ID ResourceId string `form:"resource_id"` // 资源ID
ResourceUrl string `form:"resource_url"` // 资源URL 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"` // 贴图在模型面板上的比例 Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例
SkuId int64 `form:"sku_id,default=0"` // 模板ID SkuId int64 `form:"sku_id,default=0"` // 模板ID
} }