11
This commit is contained in:
parent
77ba817569
commit
3f8fed2dd6
|
@ -2,7 +2,6 @@ package template_switch_info
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,24 +59,8 @@ type MaterialItem struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取模板开关信息(目前写死,以后后台做好了功能再更新变动)
|
// 获取模板开关信息(目前写死,以后后台做好了功能再更新变动)
|
||||||
func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMaterialImg string) (resp GetTemplateSwitchInfoRsp, err error) {
|
func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMaterialImg string) GetTemplateSwitchInfoRsp {
|
||||||
if templateJsonStr == nil || *templateJsonStr == "" {
|
returnData := GetTemplateSwitchInfoRsp{
|
||||||
return GetTemplateSwitchInfoRsp{
|
|
||||||
Id: templateId,
|
|
||||||
Material: templateMaterialImg,
|
|
||||||
MaterialData: MaterialData{
|
|
||||||
Logo: Logo{
|
|
||||||
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
var templateJsonInfo TemplateSimpleParseInfo
|
|
||||||
if err = json.Unmarshal([]byte(*templateJsonStr), &templateJsonInfo); err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return GetTemplateSwitchInfoRsp{}, errors.New("解析模板json获取DIY开关设置失败")
|
|
||||||
}
|
|
||||||
mapSwitchInfo := GetTemplateSwitchInfoRsp{
|
|
||||||
Id: templateId,
|
Id: templateId,
|
||||||
Material: templateMaterialImg,
|
Material: templateMaterialImg,
|
||||||
MaterialData: MaterialData{
|
MaterialData: MaterialData{
|
||||||
|
@ -86,6 +69,14 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if templateJsonStr == nil || *templateJsonStr == "" {
|
||||||
|
return returnData
|
||||||
|
}
|
||||||
|
var templateJsonInfo TemplateSimpleParseInfo
|
||||||
|
if err := json.Unmarshal([]byte(*templateJsonStr), &templateJsonInfo); err != nil {
|
||||||
|
logx.Error("解析模板json获取DIY开关设置失败", err)
|
||||||
|
return returnData
|
||||||
|
}
|
||||||
for _, v := range templateJsonInfo.MaterialList {
|
for _, v := range templateJsonInfo.MaterialList {
|
||||||
if v.Type == "combine" && !v.Visible {
|
if v.Type == "combine" && !v.Visible {
|
||||||
return GetTemplateSwitchInfoRsp{
|
return GetTemplateSwitchInfoRsp{
|
||||||
|
@ -96,40 +87,40 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa
|
||||||
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
switch v.Tag {
|
switch v.Tag {
|
||||||
case "Phone": //电话
|
case "Phone": //电话
|
||||||
mapSwitchInfo.MaterialData.Phone = Phone{
|
returnData.MaterialData.Phone = Phone{
|
||||||
IfShow: v.Visible,
|
IfShow: v.Visible,
|
||||||
Text: v.Text,
|
Text: v.Text,
|
||||||
DefaultValue: "000 xxx xxx 1111",
|
DefaultValue: "000 xxx xxx 1111",
|
||||||
}
|
}
|
||||||
case "Address": //地址
|
case "Address": //地址
|
||||||
mapSwitchInfo.MaterialData.Address = Address{
|
returnData.MaterialData.Address = Address{
|
||||||
IfShow: v.Visible,
|
IfShow: v.Visible,
|
||||||
Text: v.Text,
|
Text: v.Text,
|
||||||
DefaultValue: "USA",
|
DefaultValue: "USA",
|
||||||
}
|
}
|
||||||
case "Website":
|
case "Website":
|
||||||
mapSwitchInfo.MaterialData.Website = Website{
|
returnData.MaterialData.Website = Website{
|
||||||
IfShow: v.Visible,
|
IfShow: v.Visible,
|
||||||
Text: v.Text,
|
Text: v.Text,
|
||||||
DefaultValue: "https://www.xxxxxx.com",
|
DefaultValue: "https://www.xxxxxx.com",
|
||||||
}
|
}
|
||||||
case "QRcode":
|
case "QRcode":
|
||||||
mapSwitchInfo.MaterialData.QRcode = QRcode{
|
returnData.MaterialData.QRcode = QRcode{
|
||||||
IfShow: v.Visible,
|
IfShow: v.Visible,
|
||||||
Text: v.Text,
|
Text: v.Text,
|
||||||
DefaultValue: "qrcode xxxxxxx",
|
DefaultValue: "qrcode xxxxxxx",
|
||||||
}
|
}
|
||||||
case "Slogan":
|
case "Slogan":
|
||||||
mapSwitchInfo.MaterialData.Slogan = Slogan{
|
returnData.MaterialData.Slogan = Slogan{
|
||||||
IfShow: v.Visible,
|
IfShow: v.Visible,
|
||||||
Text: v.Text,
|
Text: v.Text,
|
||||||
DefaultValue: "slogan xxxxxxx",
|
DefaultValue: "slogan xxxxxxx",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mapSwitchInfo, nil
|
return returnData
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user