fix
This commit is contained in:
parent
f65f5673f8
commit
c5ef6cfa14
|
@ -7,7 +7,7 @@ import (
|
|||
// fs_product_template_tags 模板标签表
|
||||
type FsProductTemplateTags struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
Title *string `gorm:"default:'';" json:"title"` // 标题
|
||||
Title *string `gorm:"unique_key;default:'';" json:"title"` // 标题
|
||||
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||
|
|
|
@ -24,7 +24,7 @@ type FsProductTemplateV2 struct {
|
|||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
|
||||
GroupOptions *string `gorm:"default:'';" json:"group_options"` //
|
||||
Version *int64 `gorm:"default:0;" json:"version"` //
|
||||
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
|
||||
}
|
||||
type FsProductTemplateV2Model struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -111,11 +111,11 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co
|
|||
}
|
||||
|
||||
// 获取第一个尺寸下的模板
|
||||
func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, tagId string) (resp *FsProductTemplateV2, err error) {
|
||||
func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Table(t.name+" as t").
|
||||
Joins("left join fs_product_size as s on t.product_id = s.product_id").
|
||||
Select("t.*").
|
||||
Where("t.product_id = ? and t.tag = ? ", productId, tagId).
|
||||
Where("t.product_id = ? and t.tag = ? ", productId, templateTag).
|
||||
Where("t.status = ? and t.is_del = ?", 1, 0).
|
||||
Where("s.status = ?", 1).
|
||||
Order("s.sort ASC").
|
||||
|
|
|
@ -81,9 +81,9 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
|
||||
for _, v := range productTemplateTags {
|
||||
list = append(list, types.GetProductTemplateTagsRsp{
|
||||
Id: v.Id,
|
||||
Tag: *v.Title,
|
||||
Cover: *v.Cover,
|
||||
Id: v.Id,
|
||||
TemplateTag: *v.Title,
|
||||
Cover: *v.Cover,
|
||||
})
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||
|
|
|
@ -10,9 +10,9 @@ type GetProductTemplateTagsReq struct {
|
|||
}
|
||||
|
||||
type GetProductTemplateTagsRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Tag string `json:"tag"`
|
||||
Cover string `json:"cover"`
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -42,9 +42,9 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
|||
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")
|
||||
if renderImageData.RenderData.TemplateTag == "" {
|
||||
w.outChan <- 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
|
||||
}
|
||||
//获取上传最近的logo
|
||||
|
|
|
@ -20,7 +20,7 @@ type GetProductTemplateTagsReq {
|
|||
Limit int `form:"limit"`
|
||||
}
|
||||
type GetProductTemplateTagsRsp {
|
||||
Id int64 `json:"id"`
|
||||
Tag string `json:"tag"`
|
||||
Cover string `json:"cover"`
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
}
|
|
@ -12,16 +12,16 @@ type RenderImageReqMsg struct {
|
|||
RenderData RenderData `json:"render_data"`
|
||||
}
|
||||
type RenderData struct {
|
||||
TemplateTagId int64 `json:"template_tag_id"` //模板标签id
|
||||
TemplateTag string `json:"template_tag"` //模板标签
|
||||
ProductId int64 `json:"product_id"` //产品id
|
||||
UserMaterialId int64 `json:"user_material_id"` //用户素材id
|
||||
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
|
||||
/*Website string `json:"website"` //网站
|
||||
Website string `json:"website"` //网站
|
||||
Slogan string `json:"slogan"` //slogan
|
||||
Address string `json:"address"` //地址
|
||||
Phone string `json:"phone"` //电话*/
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
Phone string `json:"phone"` //电话
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
}
|
||||
|
||||
// websocket发送渲染完的数据
|
||||
|
|
Loading…
Reference in New Issue
Block a user