Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
76e0884c11
|
@ -7,7 +7,7 @@ import (
|
||||||
// fs_product_template_tags 模板标签表
|
// fs_product_template_tags 模板标签表
|
||||||
type FsProductTemplateTags struct {
|
type FsProductTemplateTags struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
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"` // 封面图
|
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
||||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||||
|
|
|
@ -24,7 +24,7 @@ type FsProductTemplateV2 struct {
|
||||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
|
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
|
||||||
GroupOptions *string `gorm:"default:'';" json:"group_options"` //
|
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 {
|
type FsProductTemplateV2Model struct {
|
||||||
db *gorm.DB
|
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").
|
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").
|
Joins("left join fs_product_size as s on t.product_id = s.product_id").
|
||||||
Select("t.*").
|
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("t.status = ? and t.is_del = ?", 1, 0).
|
||||||
Where("s.status = ?", 1).
|
Where("s.status = ?", 1).
|
||||||
Order("s.sort ASC").
|
Order("s.sort ASC").
|
||||||
|
|
|
@ -81,9 +81,9 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
||||||
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
|
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
|
||||||
for _, v := range productTemplateTags {
|
for _, v := range productTemplateTags {
|
||||||
list = append(list, types.GetProductTemplateTagsRsp{
|
list = append(list, types.GetProductTemplateTagsRsp{
|
||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
Tag: *v.Title,
|
TemplateTag: *v.Title,
|
||||||
Cover: *v.Cover,
|
Cover: *v.Cover,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||||
|
|
|
@ -10,9 +10,9 @@ type GetProductTemplateTagsReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetProductTemplateTagsRsp struct {
|
type GetProductTemplateTagsRsp struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Tag string `json:"tag"`
|
TemplateTag string `json:"template_tag"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
|
|
|
@ -4,17 +4,14 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/initalize"
|
"fusenapi/initalize"
|
||||||
"fusenapi/server/render/internal/svc"
|
"fusenapi/server/render/internal/svc"
|
||||||
"fusenapi/service/repositories"
|
"fusenapi/service/repositories"
|
||||||
"fusenapi/utils/hash"
|
|
||||||
"fusenapi/utils/websocket_data"
|
"fusenapi/utils/websocket_data"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 这里请求的py接口返回数据
|
// 这里请求的py接口返回数据
|
||||||
|
@ -52,7 +49,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
||||||
}
|
}
|
||||||
rabbitmq := initalize.RabbitMqHandle{}
|
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 err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
logx.Error("template info is not found")
|
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)
|
logx.Error("failed to get template info:", err)
|
||||||
return nil //不返回错误就删除消息
|
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{
|
res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{
|
||||||
ResourceKey: resourceKey,
|
UserId: parseInfo.RenderData.UserId,
|
||||||
TemplateId: productTemplate.Id,
|
GuestId: parseInfo.RenderData.GuestId,
|
||||||
CombineParam: string(combineParamBytes),
|
TemplateId: productTemplate.Id,
|
||||||
UserId: parseInfo.RenderData.UserId,
|
TemplateTag: parseInfo.RenderData.TemplateTag,
|
||||||
GuestId: parseInfo.RenderData.GuestId,
|
Website: parseInfo.RenderData.Website,
|
||||||
|
Slogan: parseInfo.RenderData.Slogan,
|
||||||
|
Address: parseInfo.RenderData.Address,
|
||||||
|
Phone: parseInfo.RenderData.Phone,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error("合成刀版图失败:", err)
|
logx.Error("合成刀版图失败:", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -42,9 +42,9 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||||
logx.Error("invalid format of websocket render image message:product_id")
|
logx.Error("invalid format of websocket render image message:product_id")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if renderImageData.RenderData.TemplateTagId <= 0 {
|
if renderImageData.RenderData.TemplateTag == "" {
|
||||||
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag_id ")
|
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_id")
|
logx.Error("invalid format of websocket render image message:template_tag")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//获取上传最近的logo
|
//获取上传最近的logo
|
||||||
|
|
|
@ -20,7 +20,7 @@ type GetProductTemplateTagsReq {
|
||||||
Limit int `form:"limit"`
|
Limit int `form:"limit"`
|
||||||
}
|
}
|
||||||
type GetProductTemplateTagsRsp {
|
type GetProductTemplateTagsRsp {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Tag string `json:"tag"`
|
TemplateTag string `json:"template_tag"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
}
|
}
|
|
@ -12,16 +12,16 @@ type RenderImageReqMsg struct {
|
||||||
RenderData RenderData `json:"render_data"`
|
RenderData RenderData `json:"render_data"`
|
||||||
}
|
}
|
||||||
type RenderData struct {
|
type RenderData struct {
|
||||||
TemplateTagId int64 `json:"template_tag_id"` //模板标签id
|
TemplateTag string `json:"template_tag"` //模板标签
|
||||||
ProductId int64 `json:"product_id"` //产品id
|
ProductId int64 `json:"product_id"` //产品id
|
||||||
UserMaterialId int64 `json:"user_material_id"` //用户素材id
|
UserMaterialId int64 `json:"user_material_id"` //用户素材id
|
||||||
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
|
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
|
||||||
/*Website string `json:"website"` //网站
|
Website string `json:"website"` //网站
|
||||||
Slogan string `json:"slogan"` //slogan
|
Slogan string `json:"slogan"` //slogan
|
||||||
Address string `json:"address"` //地址
|
Address string `json:"address"` //地址
|
||||||
Phone string `json:"phone"` //电话*/
|
Phone string `json:"phone"` //电话
|
||||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||||
}
|
}
|
||||||
|
|
||||||
// websocket发送渲染完的数据
|
// websocket发送渲染完的数据
|
||||||
|
|
Loading…
Reference in New Issue
Block a user