fix:合图,默认参数

This commit is contained in:
momo 2023-09-11 15:02:17 +08:00
parent 85f7dcdffb
commit e4fb6ca4a7

View File

@ -2,15 +2,18 @@ package logic
import (
"fmt"
"fusenapi/model/gmodel"
"fusenapi/service/repositories"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/template_switch_info"
"context"
"fusenapi/server/resource/internal/svc"
"fusenapi/server/resource/internal/types"
"github.com/zeromicro/go-zero/core/logc"
"github.com/zeromicro/go-zero/core/logx"
)
@ -57,6 +60,35 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
// 否则使用用户ID和用户键名格式
userId = userinfo.UserId
}
// 获取默认
if req.Address == "" || req.Phone == "" || req.Website == "" || req.Qrcode == "" {
// 没有查到先根据模版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, err := template_switch_info.GetTemplateSwitchInfo(req.TemplateId, productTemplateV2Info.TemplateInfo, *productTemplateV2Info.MaterialImg)
if err != nil {
logc.Errorf(l.ctx, "template_switch_info.GetTemplateSwitchInfoerr%v", err)
return resp.SetStatus(basic.CodeServiceErr, "默认模版不存在")
}
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
}
}
res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{
UserId: userId,
GuestId: guestId,