fix
This commit is contained in:
parent
3f73edae00
commit
ea0804ad63
|
@ -25,16 +25,45 @@ type renderImageControlChanItem struct {
|
|||
|
||||
// 渲染发送到组装数据组装数据
|
||||
func (w *wsConnectItem) renderImage(data []byte) {
|
||||
var renderImageData websocket_data.AssembleRenderData
|
||||
var renderImageData websocket_data.RenderImageReqMsg
|
||||
if err := json.Unmarshal(data, &renderImageData); err != nil {
|
||||
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))
|
||||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
logx.Info("收到请求云渲染图片数据:", renderImageData)
|
||||
if renderImageData.RenderId == "" {
|
||||
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty")
|
||||
logx.Error("invalid format of websocket render image message:render_id is empty")
|
||||
return
|
||||
}
|
||||
if renderImageData.RenderData.ProductId <= 0 {
|
||||
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:product_id ")
|
||||
logx.Error("invalid format of websocket render image message:product_id")
|
||||
return
|
||||
}
|
||||
if renderImageData.RenderData.TemplateTagId <= 0 {
|
||||
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag_id ")
|
||||
logx.Error("invalid format of websocket render image message:template_tag_id")
|
||||
return
|
||||
}
|
||||
//获取上传最近的logo
|
||||
userMaterial, err := w.allModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo")
|
||||
logx.Error("failed to get user logo")
|
||||
return
|
||||
}
|
||||
//使用默认logo(写死一个默认)
|
||||
renderImageData.RenderData.Logo = "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/f5ccd11365099fa47a6316b1cd639f6dd6064dcd2d37c8d2fcd0a322160b33cc"
|
||||
} else {
|
||||
renderImageData.RenderData.Logo = *userMaterial.ResourceUrl
|
||||
}
|
||||
//用户id赋值
|
||||
renderImageData.RenderData.UserId = w.userId
|
||||
renderImageData.RenderData.GuestId = w.guestId
|
||||
|
||||
//生成任务id
|
||||
taskId := hash.JsonHashKey(renderImageData.RenderData)
|
||||
//查询有没有缓存的资源,有就返回######################
|
||||
|
|
34
utils/curl/http_curl.go
Normal file
34
utils/curl/http_curl.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package curl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 接口请求
|
||||
func ApiCall(url, method string, header map[string]string, postData []byte, timeOut time.Duration) (rsp *http.Response, err error) {
|
||||
method = strings.ToUpper(method)
|
||||
if method != "GET" && method != "POST" && method != "PUT" && method != "DELETE" {
|
||||
return nil, errors.New("invalid http method")
|
||||
}
|
||||
if url == "" {
|
||||
return nil, errors.New("request url can`t be empty")
|
||||
}
|
||||
client := &http.Client{}
|
||||
if timeOut <= 0 {
|
||||
client.Timeout = time.Second * 15
|
||||
} else {
|
||||
client.Timeout = timeOut
|
||||
}
|
||||
requestHandle, err := http.NewRequest(method, url, bytes.NewReader(postData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range header {
|
||||
requestHandle.Header.Set(k, v)
|
||||
}
|
||||
return client.Do(requestHandle)
|
||||
}
|
|
@ -14,7 +14,7 @@ type RenderImageReqMsg struct {
|
|||
type RenderData struct {
|
||||
TemplateTagId int64 `json:"template_tag_id"` //模板标签id
|
||||
ProductId int64 `json:"product_id"` //产品id
|
||||
Logo string `json:"logo"`
|
||||
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user