fix:合图调整

This commit is contained in:
momo 2023-09-19 15:59:44 +08:00
parent 9c8f37c43c
commit 078b797c94
5 changed files with 39 additions and 47 deletions

View File

@ -45,10 +45,10 @@ func (l *UserLogoTemplateTagSetLogic) UserLogoTemplateTagSet(req *types.UserLogo
return resp.SetStatus(basic.CodeUnAuth) return resp.SetStatus(basic.CodeUnAuth)
} }
if req.LogoSelectedId == 0 { if req.LogoSelectedId == 0 {
return resp.SetStatus(basic.CodeLogoSetTemplateErr, "logo logo_selected_id not null") return resp.SetStatus(basic.CodeApiErr, "logo logo_selected_id not null")
} }
if req.TemplateTag == "" { if req.TemplateTag == "" {
return resp.SetStatus(basic.CodeLogoSetTemplateErr, "logo template tag not null") return resp.SetStatus(basic.CodeApiErr, "logo template tag not null")
} }
var userId int64 var userId int64
var guestId int64 var guestId int64

View File

@ -95,7 +95,6 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{ res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{
UserId: userId, UserId: userId,
GuestId: guestId, GuestId: guestId,
TemplateId: req.TemplateId,
TemplateTag: req.TemplateTag, TemplateTag: req.TemplateTag,
Website: req.Website, Website: req.Website,
Slogan: req.Slogan, Slogan: req.Slogan,

View File

@ -28,13 +28,16 @@ type ResourceInfoReq struct {
} }
type LogoCombineReq struct { type LogoCombineReq struct {
TemplateId int64 `form:"template_id"` // 合图参数 LogoUrl string `json:"logo_url"` // 合图参数
TemplateTag string `form:"template_tag"` // 合图参数 TemplateId int64 `json:"template_id"` // 合图参数
Website string `form:"website,optional"` // 合图参数 TemplateTag string `json:"template_tag"` // 合图参数
Slogan string `form:"slogan,optional"` // 合图参数 Color [][]string `json:"color"` // 颜色组合
Address string `form:"address,optional"` // 合图参数 SelectedIndex int `json:"selected_index"` // 主色的下标索引
Phone string `form:"phone,optional"` // 合图参数 Website string `json:"website,optional"` // 合图参数
Qrcode string `form:"qrcode,optional"` // 合图参数 Slogan string `json:"slogan,optional"` // 合图参数
Address string `json:"address,optional"` // 合图参数
Phone string `json:"phone,optional"` // 合图参数
Qrcode string `json:"qrcode,optional"` // 合图参数
} }
type Request struct { type Request struct {
@ -60,10 +63,10 @@ type File struct {
} }
type Meta struct { type Meta struct {
TotalCount int64 `json:"totalCount"` TotalCount int64 `json:"total_count"`
PageCount int64 `json:"pageCount"` PageCount int64 `json:"page_count"`
CurrentPage int `json:"currentPage"` CurrentPage int `json:"current_page"`
PerPage int `json:"perPage"` PerPage int `json:"per_page"`
} }
// Set 设置Response的Code和Message值 // Set 设置Response的Code和Message值

View File

@ -55,12 +55,15 @@ type (
type ( type (
LogoCombineReq { LogoCombineReq {
TemplateId int64 `form:"template_id"` // 合图参数 LogoUrl string `json:"logo_url"` // 合图参数
TemplateTag string `form:"template_tag"` // 合图参数 TemplateId int64 `json:"template_id"` // 合图参数
Website string `form:"website,optional"` // 合图参数 TemplateTag string `json:"template_tag"` // 合图参数
Slogan string `form:"slogan,optional"` // 合图参数 Color [][]string `json:"color"` // 颜色组合
Address string `form:"address,optional"` // 合图参数 SelectedIndex int `json:"selected_index"` // 主色的下标索引
Phone string `form:"phone,optional"` // 合图参数 Website string `json:"website,optional"` // 合图参数
Qrcode string `form:"qrcode,optional"` // 合图参数 Slogan string `json:"slogan,optional"` // 合图参数
Address string `json:"address,optional"` // 合图参数
Phone string `json:"phone,optional"` // 合图参数
Qrcode string `json:"qrcode,optional"` // 合图参数
} }
) )

View File

@ -195,17 +195,18 @@ func (l *defaultImageHandle) LogoInfoSet(ctx context.Context, in *LogoInfoSetReq
/* logo合图 */ /* logo合图 */
type ( type (
LogoCombineReq struct { LogoCombineReq struct {
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
GuestId int64 `json:"guest_id"` GuestId int64 `json:"guest_id"`
ProductTemplateV2Info *gmodel.FsProductTemplateV2 `json:"product_template_v2_info"` ProductTemplateV2Info *gmodel.FsProductTemplateV2 `json:"product_template_v2_info"`
TemplateTag string `json:"template_tag"` ProductTemplateTagGroups interface{} `json:"product_template_tag_groups"`
Website string `json:"website"` // 合图参数 TemplateTag string `json:"template_tag"`
Slogan string `json:"slogan"` // 合图参数 Website string `json:"website"` // 合图参数
Address string `json:"address"` // 合图参数 Slogan string `json:"slogan"` // 合图参数
Phone string `json:"phone"` // 合图参数 Address string `json:"address"` // 合图参数
Qrcode string `json:"qrcode"` // 合图参数 Phone string `json:"phone"` // 合图参数
LogoUrl string `json:"logo_url"` // 合图参数 Qrcode string `json:"qrcode"` // 合图参数
TemplateTagColor TemplateTagColor `json:"template_tag_color"` //合图颜色 LogoUrl string `json:"logo_url"` // 合图参数
TemplateTagColor TemplateTagColor `json:"template_tag_color"` //合图颜色
} }
LogoCombineRes struct { LogoCombineRes struct {
ResourceId string ResourceId string
@ -257,13 +258,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
} }
} }
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 groupOptions map[string]interface{}
var materialList []interface{} var materialList []interface{}
if in.ProductTemplateV2Info.TemplateInfo != nil { if in.ProductTemplateV2Info.TemplateInfo != nil {
@ -297,13 +291,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
moduleDataMap["groupOptions"] = groupOptions moduleDataMap["groupOptions"] = groupOptions
moduleDataMap["materialList"] = materialList 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{} var combineParam map[string]interface{}
json.Unmarshal([]byte(*resLogoInfo.Metadata), &combineParam) json.Unmarshal([]byte(*resLogoInfo.Metadata), &combineParam)
combineParam["template_tagid"] = in.TemplateTag combineParam["template_tagid"] = in.TemplateTag
@ -319,7 +306,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
} }
var postMap = make(map[string]interface{}, 2) var postMap = make(map[string]interface{}, 2)
postMap["module_data"] = moduleDataMap postMap["module_data"] = moduleDataMap
postMap["tag_data"] = tagDataMap postMap["tag_data"] = in.ProductTemplateTagGroups
postMap["param_data"] = combineParam postMap["param_data"] = combineParam
logc.Infof(ctx, "合图--算法请求--合图--开始时间:%v", time.Now().UTC()) logc.Infof(ctx, "合图--算法请求--合图--开始时间:%v", time.Now().UTC())