This commit is contained in:
laodaming
2023-08-15 11:18:22 +08:00
parent f65f5673f8
commit c5ef6cfa14
9 changed files with 30 additions and 49 deletions

View File

@@ -4,17 +4,14 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"fusenapi/constants"
"fusenapi/initalize"
"fusenapi/server/render/internal/svc"
"fusenapi/service/repositories"
"fusenapi/utils/hash"
"fusenapi/utils/websocket_data"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
"strconv"
"time"
)
// 这里请求的py接口返回数据
@@ -52,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, fmt.Sprintf("%d", parseInfo.RenderData.TemplateTagId))
productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, parseInfo.RenderData.TemplateTag)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
logx.Error("template info is not found")
@@ -61,33 +58,17 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
logx.Error("failed to get template info:", err)
return nil //不返回错误就删除消息
}
time.Now().UTC()
resourceKey := hash.JsonHashKey(parseInfo)
combineParam := map[string]interface{}{
"logo_url": parseInfo.RenderData.Logo,
"website": "",
"slogan": "",
"address": "",
"phone": "",
"colors": []string{},
"template_tagid": "b1a",
"is_crop": false,
"shape": "rectangle",
"ratio": 0,
"line": "",
"other": "",
"other1": "",
}
combineParamBytes, _ := json.Marshal(combineParam)
//获取刀版图
res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{
ResourceKey: resourceKey,
TemplateId: productTemplate.Id,
CombineParam: string(combineParamBytes),
UserId: parseInfo.RenderData.UserId,
GuestId: parseInfo.RenderData.GuestId,
UserId: parseInfo.RenderData.UserId,
GuestId: parseInfo.RenderData.GuestId,
TemplateId: productTemplate.Id,
TemplateTag: parseInfo.RenderData.TemplateTag,
Website: parseInfo.RenderData.Website,
Slogan: parseInfo.RenderData.Slogan,
Address: parseInfo.RenderData.Address,
Phone: parseInfo.RenderData.Phone,
})
if err != nil {
logx.Error("合成刀版图失败:", err)
return nil