11
This commit is contained in:
parent
a39076d739
commit
4d0081b19c
|
@ -7,6 +7,7 @@ import (
|
|||
"fusenapi/constants"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/template_switch_info"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
|
||||
|
@ -111,36 +112,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||
}*/
|
||||
modelInfo := modelList[modelIndex]
|
||||
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
|
||||
rsp[mapKey] = map[string]interface{}{
|
||||
"id": templateInfo.Id,
|
||||
"material": *templateInfo.MaterialImg,
|
||||
//写死的数据
|
||||
"material_data": map[string]interface{}{
|
||||
"QRcode": map[string]interface{}{
|
||||
"if_show": true,
|
||||
"text": "qrcode",
|
||||
"default_value": "default qrcode",
|
||||
},
|
||||
"Website": map[string]interface{}{
|
||||
"if_show": true,
|
||||
"text": "website",
|
||||
"default_value": "default website",
|
||||
},
|
||||
"Address": map[string]interface{}{
|
||||
"if_show": true,
|
||||
"text": "address",
|
||||
"default_value": "default address",
|
||||
},
|
||||
"Phone": map[string]interface{}{
|
||||
"if_show": true,
|
||||
"text": "phone",
|
||||
"default_value": "17557283679",
|
||||
},
|
||||
"Logo": map[string]interface{}{
|
||||
"material": "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||
},
|
||||
},
|
||||
}
|
||||
rsp[mapKey] = template_switch_info.GetTemplateSwitchInfo(templateInfo.Id, *templateInfo.MaterialImg)
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp)
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ var (
|
|||
//渲染任务缓冲队列长度
|
||||
renderChanLen = 500
|
||||
//是否开启debug
|
||||
openDebug = false
|
||||
openDebug = true
|
||||
//允许跨域的origin
|
||||
mapAllowOrigin = map[string]struct{}{
|
||||
"https://www.fusen.3718.cn": struct{}{},
|
||||
|
@ -118,11 +118,13 @@ type wsConnectItem struct {
|
|||
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
|
||||
origin := r.Header.Get("Origin")
|
||||
//判断是不是允许的跨域
|
||||
upgrader.CheckOrigin = func(r *http.Request) bool {
|
||||
if _, ok := mapAllowOrigin[origin]; !ok {
|
||||
return false
|
||||
if !openDebug {
|
||||
upgrader.CheckOrigin = func(r *http.Request) bool {
|
||||
if _, ok := mapAllowOrigin[origin]; !ok {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
//把子协议携带的token设置到标准token头信息中
|
||||
token := r.Header.Get("Sec-Websocket-Protocol")
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"fusenapi/service/repositories"
|
||||
"fusenapi/utils/curl"
|
||||
"fusenapi/utils/hash"
|
||||
"fusenapi/utils/template_switch_info"
|
||||
"fusenapi/utils/websocket_data"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
|
@ -135,6 +136,20 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
|||
logx.Error("failed to get element ,", err)
|
||||
return
|
||||
}
|
||||
//获取模板开关信息并且对于没有默认值的给赋值默认值
|
||||
templateSwitchInfo := template_switch_info.GetTemplateSwitchInfo(productTemplate.Id, *productTemplate.MaterialImg)
|
||||
if renderImageData.RenderData.Website == "" {
|
||||
renderImageData.RenderData.Website = templateSwitchInfo.MaterialData.Website.DefaultValue
|
||||
}
|
||||
if renderImageData.RenderData.Phone == "" {
|
||||
renderImageData.RenderData.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue
|
||||
}
|
||||
if renderImageData.RenderData.Address == "" {
|
||||
renderImageData.RenderData.Address = templateSwitchInfo.MaterialData.Address.DefaultValue
|
||||
}
|
||||
if renderImageData.RenderData.Qrcode == "" {
|
||||
renderImageData.RenderData.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue
|
||||
}
|
||||
//获取刀版图
|
||||
combineReq := repositories.LogoCombineReq{
|
||||
UserId: renderImageData.RenderData.UserId,
|
||||
|
|
71
utils/template_switch_info/template_switch.go
Normal file
71
utils/template_switch_info/template_switch.go
Normal file
|
@ -0,0 +1,71 @@
|
|||
package template_switch_info
|
||||
|
||||
type GetTemplateSwitchInfoRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Material string `json:"material"`
|
||||
MaterialData MaterialData `json:"material_data"`
|
||||
}
|
||||
type MaterialData struct {
|
||||
QRcode QRcode `json:"QRcode"`
|
||||
Website Website `json:"Website"`
|
||||
Address Address `json:"Address"`
|
||||
Phone Phone `json:"Phone"`
|
||||
Logo Logo `json:"Logo"`
|
||||
}
|
||||
type QRcode struct {
|
||||
IfShow bool `json:"if_show"`
|
||||
Text string `json:"text"`
|
||||
DefaultValue string `json:"default_value"`
|
||||
}
|
||||
type Website struct {
|
||||
IfShow bool `json:"if_show"`
|
||||
Text string `json:"text"`
|
||||
DefaultValue string `json:"default_value"`
|
||||
}
|
||||
type Address struct {
|
||||
IfShow bool `json:"if_show"`
|
||||
Text string `json:"text"`
|
||||
DefaultValue string `json:"default_value"`
|
||||
}
|
||||
type Phone struct {
|
||||
IfShow bool `json:"if_show"`
|
||||
Text string `json:"text"`
|
||||
DefaultValue string `json:"default_value"`
|
||||
}
|
||||
type Logo struct {
|
||||
Material string `json:"material"`
|
||||
}
|
||||
|
||||
// 获取模板开关信息(目前写死,以后后台做好了功能再更新变动)
|
||||
func GetTemplateSwitchInfo(templateId int64, templateMaterialImg string) GetTemplateSwitchInfoRsp {
|
||||
return GetTemplateSwitchInfoRsp{
|
||||
Id: templateId,
|
||||
Material: templateMaterialImg,
|
||||
MaterialData: MaterialData{
|
||||
QRcode: QRcode{
|
||||
IfShow: true,
|
||||
Text: "qrcode",
|
||||
DefaultValue: "default qrcode",
|
||||
},
|
||||
Website: Website{
|
||||
IfShow: true,
|
||||
Text: "website",
|
||||
DefaultValue: "default website",
|
||||
},
|
||||
Address: Address{
|
||||
IfShow: true,
|
||||
Text: "address",
|
||||
DefaultValue: "default address",
|
||||
},
|
||||
Phone: Phone{
|
||||
IfShow: true,
|
||||
Text: "phone",
|
||||
DefaultValue: "17557283679",
|
||||
},
|
||||
Logo: Logo{
|
||||
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user