fix:合图调整

This commit is contained in:
momo
2023-09-19 17:28:14 +08:00
parent ab5f908300
commit 75849f0ab8
3 changed files with 85 additions and 48 deletions

View File

@@ -6,7 +6,6 @@ import (
"fusenapi/service/repositories"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/template_switch_info"
"context"
@@ -64,33 +63,41 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
// 否则使用用户ID和用户键名格式
userId = userinfo.UserId
}
// 获取默认
if req.Address == "" || req.Phone == "" || req.Website == "" || req.Qrcode == "" || req.Slogan == "" {
// 没有查到先根据模版id 查询模版数据 请求算法数据
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId)
// 没有查到先根据模版id 查询模版数据 请求算法数据
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId)
if err != nil {
logc.Errorf(l.ctx, "productTemplateV2Model.FindOne%v", err)
return resp.SetStatus(basic.CodeServiceErr, "模版不存在")
}
templateSwitchInfo := template_switch_info.GetTemplateSwitchInfo(req.TemplateId, productTemplateV2Info.TemplateInfo, *productTemplateV2Info.MaterialImg)
if req.Address == "" && templateSwitchInfo.MaterialData.Address.IfShow {
req.Address = templateSwitchInfo.MaterialData.Address.DefaultValue
}
if req.Phone == "" && templateSwitchInfo.MaterialData.Phone.IfShow {
req.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue
}
if req.Website == "" && templateSwitchInfo.MaterialData.Website.IfShow {
req.Website = templateSwitchInfo.MaterialData.Website.DefaultValue
}
if req.Qrcode == "" && templateSwitchInfo.MaterialData.QRcode.IfShow {
req.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue
}
if req.Slogan == "" && templateSwitchInfo.MaterialData.Slogan.IfShow {
req.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue
}
if err != nil {
logc.Errorf(l.ctx, "productTemplateV2Model.FindOne%v", err)
return resp.SetStatus(basic.CodeServiceErr, "模版不存在")
}
// // 获取默认
// if req.Address == "" || req.Phone == "" || req.Website == "" || req.Qrcode == "" || req.Slogan == "" {
// // 没有查到先根据模版id 查询模版数据 请求算法数据
// productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
// productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId)
// if err != nil {
// logc.Errorf(l.ctx, "productTemplateV2Model.FindOne%v", err)
// return resp.SetStatus(basic.CodeServiceErr, "模版不存在")
// }
// templateSwitchInfo := template_switch_info.GetTemplateSwitchInfo(req.TemplateId, productTemplateV2Info.TemplateInfo, *productTemplateV2Info.MaterialImg)
// if req.Address == "" && templateSwitchInfo.MaterialData.Address.IfShow {
// req.Address = templateSwitchInfo.MaterialData.Address.DefaultValue
// }
// if req.Phone == "" && templateSwitchInfo.MaterialData.Phone.IfShow {
// req.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue
// }
// if req.Website == "" && templateSwitchInfo.MaterialData.Website.IfShow {
// req.Website = templateSwitchInfo.MaterialData.Website.DefaultValue
// }
// if req.Qrcode == "" && templateSwitchInfo.MaterialData.QRcode.IfShow {
// req.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue
// }
// if req.Slogan == "" && templateSwitchInfo.MaterialData.Slogan.IfShow {
// req.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue
// }
// }
res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{
UserId: userId,
@@ -100,8 +107,14 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
Slogan: req.Slogan,
Phone: req.Phone,
Address: req.Address,
Qrcode: req.Qrcode,
Qrcode: req.Qrcode,
LogoUrl: req.LogoUrl,
TemplateTagColor: repositories.TemplateTagColor{
Color: req.TemplateTagColor.Colors,
Index: req.TemplateTagColor.SelectedColorIndex,
},
ProductTemplateTagGroups: req.TemplateTagGroups,
ProductTemplateV2Info: productTemplateV2Info,
})
if err != nil {