Merge branch 'feature/mhw-v1.01' of gitee.com:fusenpack/fusenapi into feature/mhw-v1.01
This commit is contained in:
@@ -54,15 +54,16 @@ type (
|
||||
GuestId int64 `json:"guest_id"`
|
||||
}
|
||||
LogoInfoRes struct {
|
||||
Metadata *string `json:"metadata"`
|
||||
LogoUrl *string `json:"logo_url"`
|
||||
Metadata *string `json:"metadata"`
|
||||
LogoUrl *string `json:"logo_url"`
|
||||
UserInfoMetadata *string `json:"user_info_metadata"`
|
||||
}
|
||||
)
|
||||
|
||||
func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error) {
|
||||
var metadata *string
|
||||
var logoUrl *string
|
||||
|
||||
var userInfoMetadata *string
|
||||
// 更新用户信息
|
||||
var module = "profile"
|
||||
userInfoGorm := l.MysqlConn.Where("module = ?", module)
|
||||
@@ -82,30 +83,42 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if userInfo.Id != 0 {
|
||||
tmp := string(*userInfo.Metadata)
|
||||
userInfoMetadata = &tmp
|
||||
}
|
||||
var userMaterialInfo gmodel.FsUserMaterial
|
||||
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
|
||||
|
||||
var metadataUserInfo struct {
|
||||
LogoSelected struct {
|
||||
TemplateTagSelected *struct {
|
||||
Color [][]string `json:"color"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
SelectedIndex int64 `json:"selected_index"`
|
||||
} `json:"template_tag_selected"`
|
||||
LogoSelectedId int64 `json:"logo_selected_id"`
|
||||
} `json:"logo_selected"`
|
||||
}
|
||||
userInfo.Id = 0
|
||||
if userInfo.Id == 0 {
|
||||
userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
if err != nil && err != gorm.ErrRecordNotFound {
|
||||
logc.Errorf(ctx, "FsUserMaterial FindLatestOne err:%+v", err)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
if userInfo.Metadata != nil {
|
||||
var metadata map[string]interface{}
|
||||
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadata)
|
||||
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo)
|
||||
if err != nil {
|
||||
logc.Errorf(ctx, "userInfo.Metadata Unmarshal err:%+v", err)
|
||||
return nil, err
|
||||
}
|
||||
logoSelectedId, isEx := metadata["logo_selected_id"]
|
||||
if isEx {
|
||||
var materialId int64 = int64(logoSelectedId.(float64))
|
||||
userMaterialInfos, err := userMaterialModel.FindOneById(ctx, materialId)
|
||||
|
||||
if metadataUserInfo.LogoSelected.LogoSelectedId != 0 {
|
||||
userMaterialInfos, err := userMaterialModel.FindOneById(ctx, metadataUserInfo.LogoSelected.LogoSelectedId)
|
||||
if err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
logc.Errorf(ctx, "FsUserInfo First err:%+v", err)
|
||||
logc.Errorf(ctx, "userMaterial findOneById err:%+v", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -134,8 +147,9 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
|
||||
logoUrl = userMaterialInfo.ResourceUrl
|
||||
}
|
||||
return &LogoInfoRes{
|
||||
Metadata: metadata,
|
||||
LogoUrl: logoUrl,
|
||||
Metadata: metadata,
|
||||
LogoUrl: logoUrl,
|
||||
UserInfoMetadata: userInfoMetadata,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -181,16 +195,18 @@ func (l *defaultImageHandle) LogoInfoSet(ctx context.Context, in *LogoInfoSetReq
|
||||
/* logo合图 */
|
||||
type (
|
||||
LogoCombineReq struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
GuestId int64 `json:"guest_id"`
|
||||
TemplateId int64 `json:"template_id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Website string `json:"website"` // 合图参数
|
||||
Slogan string `json:"slogan"` // 合图参数
|
||||
Address string `json:"address"` // 合图参数
|
||||
Phone string `json:"phone"` // 合图参数
|
||||
Qrcode string `json:"qrcode"` // 合图参数
|
||||
LogoUrl string `json:"logo_url"` // 合图参数
|
||||
UserId int64 `json:"user_id"`
|
||||
GuestId int64 `json:"guest_id"`
|
||||
ProductTemplateV2Info *gmodel.FsProductTemplateV2 `json:"product_template_v2_info"`
|
||||
ProductTemplateTagGroups interface{} `json:"product_template_tag_groups"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Website string `json:"website"` // 合图参数
|
||||
Slogan string `json:"slogan"` // 合图参数
|
||||
Address string `json:"address"` // 合图参数
|
||||
Phone string `json:"phone"` // 合图参数
|
||||
Qrcode string `json:"qrcode"` // 合图参数
|
||||
LogoUrl string `json:"logo_url"` // 合图参数
|
||||
TemplateTagColor TemplateTagColor `json:"template_tag_color"` //合图颜色
|
||||
}
|
||||
LogoCombineRes struct {
|
||||
ResourceId string
|
||||
@@ -200,6 +216,10 @@ type (
|
||||
DiffTimeUploadFile int64
|
||||
}
|
||||
)
|
||||
type TemplateTagColor struct {
|
||||
Color [][]string `json:"color"`
|
||||
Index int `json:"index"`
|
||||
}
|
||||
|
||||
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
|
||||
// 查询logo最新基础信息
|
||||
@@ -238,27 +258,11 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
||||
}
|
||||
}
|
||||
|
||||
// 没有查到,先根据模版id 查询模版数据 请求算法数据
|
||||
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.MysqlConn)
|
||||
productTemplateV2Info, err := productTemplateV2Model.FindOne(ctx, in.TemplateId)
|
||||
|
||||
if err != nil {
|
||||
logc.Errorf(ctx, "productTemplateV2Model.FindOne:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
productTemplateTagInfo, err := gmodel.NewFsProductTemplateTagsModel(l.MysqlConn).FindOneByTagName(ctx, in.TemplateTag, "groups")
|
||||
|
||||
if err != nil {
|
||||
logc.Errorf(ctx, "NewFsProductTemplateTagsModel.FindOneByTagName:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var groupOptions map[string]interface{}
|
||||
var materialList []interface{}
|
||||
if productTemplateV2Info.TemplateInfo != nil {
|
||||
if in.ProductTemplateV2Info.TemplateInfo != nil {
|
||||
var templateInfo map[string]interface{}
|
||||
err = json.Unmarshal([]byte(*productTemplateV2Info.TemplateInfo), &templateInfo)
|
||||
err = json.Unmarshal([]byte(*in.ProductTemplateV2Info.TemplateInfo), &templateInfo)
|
||||
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
@@ -282,18 +286,11 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
||||
}
|
||||
|
||||
var moduleDataMap = make(map[string]interface{}, 4)
|
||||
moduleDataMap["id"] = productTemplateV2Info.Id
|
||||
moduleDataMap["material"] = productTemplateV2Info.MaterialImg
|
||||
moduleDataMap["id"] = in.ProductTemplateV2Info.Id
|
||||
moduleDataMap["material"] = in.ProductTemplateV2Info.MaterialImg
|
||||
moduleDataMap["groupOptions"] = groupOptions
|
||||
moduleDataMap["materialList"] = materialList
|
||||
|
||||
var tagDataMap []interface{}
|
||||
err = json.Unmarshal([]byte(*productTemplateTagInfo.Groups), &tagDataMap)
|
||||
if err != nil {
|
||||
logc.Errorf(ctx, "Unmarshal tagDataMap:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var combineParam map[string]interface{}
|
||||
json.Unmarshal([]byte(*resLogoInfo.Metadata), &combineParam)
|
||||
combineParam["template_tagid"] = in.TemplateTag
|
||||
@@ -302,10 +299,14 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
||||
combineParam["phone"] = in.Phone
|
||||
combineParam["address"] = in.Address
|
||||
combineParam["qrcode"] = in.Qrcode
|
||||
|
||||
combineParam["template_tag_selected"] = map[string]interface{}{
|
||||
"template_tag": in.TemplateTag,
|
||||
"color": in.TemplateTagColor.Color,
|
||||
"index": in.TemplateTagColor.Index,
|
||||
}
|
||||
var postMap = make(map[string]interface{}, 2)
|
||||
postMap["module_data"] = moduleDataMap
|
||||
postMap["tag_data"] = tagDataMap
|
||||
postMap["tag_data"] = in.ProductTemplateTagGroups
|
||||
postMap["param_data"] = combineParam
|
||||
|
||||
logc.Infof(ctx, "合图--算法请求--合图--开始时间:%v", time.Now().UTC())
|
||||
|
||||
Reference in New Issue
Block a user