This commit is contained in:
laodaming 2023-08-15 15:09:53 +08:00
parent e8f7bda7b2
commit a3015e9fdd
3 changed files with 20 additions and 10 deletions

View File

@ -49,7 +49,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
}
rabbitmq := initalize.RabbitMqHandle{}
//获取模板(模板标签下的对一个物料的的模板)
productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, parseInfo.RenderData.TemplateTag)
productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, "8" /*parseInfo.RenderData.TemplateTag*/)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
logx.Error("template info is not found")
@ -80,7 +80,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
return nil
}
logx.Info("合成刀版图成功")
logx.Info("合成刀版图成功:", *res.ResourceUrl)
//获取渲染设置信息
element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId)
if err != nil {

View File

@ -303,7 +303,7 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) {
var parseInfo websocket_data.DataTransferData
if err := json.Unmarshal(data, &parseInfo); err != nil {
logx.Error("invalid format of websocket message")
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data))
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data)))
return
}
d, _ := json.Marshal(parseInfo.D)

View File

@ -27,23 +27,23 @@ type renderImageControlChanItem struct {
func (w *wsConnectItem) renderImage(data []byte) {
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))
w.sendToOutChan(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")
w.sendToOutChan(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 ")
w.sendToOutChan(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.TemplateTag == "" {
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag ")
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag "))
logx.Error("invalid format of websocket render image message:template_tag")
return
}
@ -51,12 +51,22 @@ func (w *wsConnectItem) renderImage(data []byte) {
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")
w.sendToOutChan(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"
//使用默认logo(id=0)
userMaterialDefault, err := w.allModels.FsUserMaterial.FindOneById(w.ctx, 0)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "default logo is not exists"))
return
}
logx.Error("default logo is not exists")
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get default logo"))
return
}
renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl
} else {
renderImageData.RenderData.Logo = *userMaterial.ResourceUrl
}