Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
a80a71255a
@ -5,7 +5,7 @@ import "context"
|
|||||||
// TODO: 使用model的属性做你想做的
|
// TODO: 使用model的属性做你想做的
|
||||||
type GetTagPropByProductIdsWithProductTagRsp struct {
|
type GetTagPropByProductIdsWithProductTagRsp struct {
|
||||||
FsProductTagProp
|
FsProductTagProp
|
||||||
Title string `json:"title"`
|
TemplateTag string `json:"template_tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context.Context, productIds []int64) (resp []GetTagPropByProductIdsWithProductTagRsp, err error) {
|
func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context.Context, productIds []int64) (resp []GetTagPropByProductIdsWithProductTagRsp, err error) {
|
||||||
@ -14,7 +14,7 @@ func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context
|
|||||||
}
|
}
|
||||||
err = p.db.WithContext(ctx).Table(p.name+" as p ").
|
err = p.db.WithContext(ctx).Table(p.name+" as p ").
|
||||||
Joins("left join fs_product_template_tags as t on p.template_tag_id = t.id").
|
Joins("left join fs_product_template_tags as t on p.template_tag_id = t.id").
|
||||||
Select("p.*,t.title as title").
|
Select("p.*,t.template_tag as template_tag").
|
||||||
Where("p.product_id in (?) and p.status = ? and t.status = ?", productIds, 1, 1).
|
Where("p.product_id in (?) and p.status = ? and t.status = ?", productIds, 1, 1).
|
||||||
Find(&resp).Error
|
Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
|
@ -11,9 +11,3 @@ func (e *FsProductTemplateElementModel) FindOneByModelId(ctx context.Context, mo
|
|||||||
Take(&resp).Error
|
Take(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
func (e *FsProductTemplateElementModel) FindRandOne(ctx context.Context) (resp *FsProductTemplateElement, err error) {
|
|
||||||
err = e.db.WithContext(ctx).Model(&FsProductTemplateElement{}).
|
|
||||||
Order("RAND()").
|
|
||||||
Take(&resp).Error
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
|
@ -6,12 +6,12 @@ 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:"unique_key;default:'';" json:"title"` // 标题
|
TemplateTag *string `gorm:"unique_key;default:'';" json:"template_tag"` // 标题
|
||||||
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"` // 创建时间
|
||||||
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息
|
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息
|
||||||
}
|
}
|
||||||
type FsProductTemplateTagsModel struct {
|
type FsProductTemplateTagsModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -36,7 +36,7 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag
|
|||||||
if len(tagNames) == 0 {
|
if len(tagNames) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", tagNames, 1)
|
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` in (?) and `status` = ?", tagNames, 1)
|
||||||
if orderBy != "" {
|
if orderBy != "" {
|
||||||
db = db.Order(orderBy)
|
db = db.Order(orderBy)
|
||||||
}
|
}
|
||||||
@ -44,6 +44,6 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string) (resp *FsProductTemplateTags, err error) {
|
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string) (resp *FsProductTemplateTags, err error) {
|
||||||
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` = ? and `status` = ?", tagName, 1).Take(&resp).Error
|
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1).Take(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,9 @@ type FsProductTemplateV2 struct {
|
|||||||
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Tag *string `gorm:"default:'';" json:"tag"` //
|
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
||||||
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"` //
|
|
||||||
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
|
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
|
||||||
}
|
}
|
||||||
type FsProductTemplateV2Model struct {
|
type FsProductTemplateV2Model struct {
|
||||||
|
@ -115,7 +115,7 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont
|
|||||||
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, templateTag).
|
Where("t.product_id = ? and t.template_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").
|
||||||
@ -126,7 +126,7 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont
|
|||||||
if len(modelIds) == 0 {
|
if len(modelIds) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1)
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `template_tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1)
|
||||||
if len(fields) != 0 {
|
if len(fields) != 0 {
|
||||||
db = db.Select(fields[0])
|
db = db.Select(fields[0])
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont
|
|||||||
// 获取产品在指定模板标签下的所有模板
|
// 获取产品在指定模板标签下的所有模板
|
||||||
func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||||
Where("tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0)
|
Where("template_tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0)
|
||||||
if len(fields) > 0 {
|
if len(fields) > 0 {
|
||||||
db = db.Select(fields[0])
|
db = db.Select(fields[0])
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||||||
for _, v := range productTemplateTags {
|
for _, v := range productTemplateTags {
|
||||||
list = append(list, types.GetProductTemplateTagsRsp{
|
list = append(list, types.GetProductTemplateTagsRsp{
|
||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
TemplateTag: *v.Title,
|
TemplateTag: *v.TemplateTag,
|
||||||
Cover: *v.Cover,
|
Cover: *v.Cover,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
tagIds := make([]int64, 0, len(productTemplateList))
|
tagIds := make([]int64, 0, len(productTemplateList))
|
||||||
for _, v := range productTemplateList {
|
for _, v := range productTemplateList {
|
||||||
mapTemplateModelId[*v.ModelId] = struct{}{}
|
mapTemplateModelId[*v.ModelId] = struct{}{}
|
||||||
if v.Tag != nil && *v.Tag != "" {
|
if v.TemplateTag != nil && *v.TemplateTag != "" {
|
||||||
tagId, err := strconv.ParseInt(*v.Tag, 10, 64)
|
tagId, err := strconv.ParseInt(*v.TemplateTag, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not a number")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not a number")
|
||||||
@ -296,7 +296,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
partListRsp = append(partListRsp, thisInfo)
|
partListRsp = append(partListRsp, thisInfo)
|
||||||
}
|
}
|
||||||
tagName := ""
|
tagName := ""
|
||||||
if tagData, ok := mapTag[*tmp.Tag]; ok {
|
if tagData, ok := mapTag[*tmp.TemplateTag]; ok {
|
||||||
tagName = *tagData.Title
|
tagName = *tagData.Title
|
||||||
}
|
}
|
||||||
//按照材质和尺寸来存放模板信息
|
//按照材质和尺寸来存放模板信息
|
||||||
|
@ -127,7 +127,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
||||||
for _, v := range productTagPropList {
|
for _, v := range productTagPropList {
|
||||||
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||||
Tag: v.Title,
|
Tag: v.TemplateTag,
|
||||||
Cover: *v.Cover,
|
Cover: *v.Cover,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
}
|
}
|
||||||
for _, v := range productTagPropList {
|
for _, v := range productTagPropList {
|
||||||
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||||
Tag: v.Title,
|
Tag: v.TemplateTag,
|
||||||
Cover: *v.Cover,
|
Cover: *v.Cover,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,15 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||||||
} else { //指定物料
|
} else { //指定物料
|
||||||
sizeIds = append(sizeIds, req.ProductSizeId)
|
sizeIds = append(sizeIds, req.ProductSizeId)
|
||||||
}
|
}
|
||||||
|
//获取templatetag信息
|
||||||
|
templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOne(l.ctx, req.ProductTemplateTagId)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag is not exists")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get template tag")
|
||||||
|
}
|
||||||
//根据尺寸id获取模型
|
//根据尺寸id获取模型
|
||||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
|
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -83,7 +92,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||||||
mapModel[v.Id] = k
|
mapModel[v.Id] = k
|
||||||
}
|
}
|
||||||
//查询模型ids下对应tag标签的模板
|
//查询模型ids下对应tag标签的模板
|
||||||
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, fmt.Sprintf("%d", req.ProductTemplateTagId), "")
|
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, *templateTagInfo.TemplateTag, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
|
||||||
|
@ -156,7 +156,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
|||||||
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
||||||
for _, v := range productTagPropList {
|
for _, v := range productTagPropList {
|
||||||
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||||
Tag: v.Title,
|
Tag: v.TemplateTag,
|
||||||
Cover: *v.Cover,
|
Cover: *v.Cover,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -96,5 +96,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
|||||||
ws.sendToOutChan(b)
|
ws.sendToOutChan(b)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
logx.Info("渲染回调成功######################")
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,8 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
logx.Error("assembleRenderData panic:", err)
|
logx.Error("assembleRenderData panic:", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数
|
//获取模板
|
||||||
productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16")
|
productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, info.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")
|
||||||
@ -188,9 +188,15 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
}
|
}
|
||||||
logx.Info("合成刀版图成功:", *res.ResourceUrl)
|
logx.Info("合成刀版图成功:", *res.ResourceUrl)
|
||||||
//获取渲染设置信息
|
//获取渲染设置信息
|
||||||
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindRandOne(w.logic.ctx /*, *productTemplate.ModelId*/)
|
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
// todo 没有图就给他返回一张默认(后面要删除)
|
||||||
|
defaultImg := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||||
|
RenderId: info.RenderId,
|
||||||
|
Image: "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/695463af6e9b93c003db39ddf728241f9523efc55b20dc37f30fe5d96ed54fb5",
|
||||||
|
})
|
||||||
|
w.sendToOutChan(defaultImg)
|
||||||
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user