Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-08-11 18:59:11 +08:00
commit f8792a9c2b
3 changed files with 24 additions and 7 deletions

View File

@ -16,5 +16,5 @@ AWS:
Token: Token:
BLMService: BLMService:
LogoCombine: LogoCombine:
#Url: "http://192.168.1.7:45678/LogoCombine" #Url: "http://192.168.1.7:8999/LogoCombine"
Url: "http://18.119.109.254:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine"

View File

@ -2,14 +2,16 @@ package logic
import ( import (
"encoding/json" "encoding/json"
"errors"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/basic" "fusenapi/utils/basic"
"fusenapi/utils/curl"
"fusenapi/utils/file" "fusenapi/utils/file"
"fusenapi/utils/hash" "fusenapi/utils/hash"
"io" "io"
"net/http"
"strings" "strings"
"time"
"context" "context"
@ -17,6 +19,7 @@ import (
"fusenapi/server/resource/internal/types" "fusenapi/server/resource/internal/types"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
) )
type LogoCombineLogic struct { type LogoCombineLogic struct {
@ -75,8 +78,10 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
}) })
} else { } else {
if err != nil { if err != nil {
logx.Error(err) if !errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error") logx.Error(err)
return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error")
}
} }
} }
@ -123,7 +128,11 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
postMap["param_data"] = combineParam postMap["param_data"] = combineParam
postMapB, _ := json.Marshal(postMap) postMapB, _ := json.Marshal(postMap)
result, err := http.Post(l.svcCtx.Config.BLMService.LogoCombine.Url, "application/json", strings.NewReader(string(postMapB))) //result, err := http.Post(l.svcCtx.Config.BLMService.LogoCombine.Url, "application/json", strings.NewReader(string(postMapB)))
var headerData = make(map[string]string, 1)
headerData["Content-Type"] = "application/json"
result, err := curl.ApiCall(l.svcCtx.Config.BLMService.LogoCombine.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20)
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeFileLogoCombineErr, "service post fail") return resp.SetStatus(basic.CodeFileLogoCombineErr, "service post fail")
@ -134,8 +143,9 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail")
} }
ress := string(b)
if string(b) == "Internal Server Error" { if ress == "Internal Server Error" {
return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail")
} }

View File

@ -168,5 +168,12 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
} }
return resp.SetStatus(basic.CodeOK) // 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"upload_data": UploadUrl{
Status: 1,
ResourceId: uploadRes.ResourceId,
ResourceUrl: uploadRes.ResourceUrl,
},
})
} }