fix:合图调整
This commit is contained in:
parent
e0a851ba25
commit
dbb1591cbb
|
@ -92,6 +92,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/api/user/logo-set",
|
Path: "/api/user/logo-set",
|
||||||
Handler: UserLogoSetHandler(serverCtx),
|
Handler: UserLogoSetHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/user/logo-templatetag-set",
|
||||||
|
Handler: UserLogoTemplateTagSetHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/home-user-auth/internal/logic"
|
||||||
|
"fusenapi/server/home-user-auth/internal/svc"
|
||||||
|
"fusenapi/server/home-user-auth/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UserLogoTemplateTagSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.UserLogoTemplateTagSetReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewUserLogoTemplateTagSetLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.UserLogoTemplateTagSet(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,17 +75,16 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
|
||||||
|
|
||||||
var nowTime = time.Now().UTC()
|
var nowTime = time.Now().UTC()
|
||||||
err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
|
err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
|
var metadataMapOldUserMaterial map[string]interface{}
|
||||||
|
if userMaterialInfo.Metadata != nil {
|
||||||
|
err = json.Unmarshal(*userMaterialInfo.Metadata, &metadataMapOldUserMaterial)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "userMaterialInfo Metadata Unmarshal err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
// 更新merchant_category
|
// 更新merchant_category
|
||||||
if req.SetLogoCategory == 1 {
|
if req.SetLogoCategory == 1 {
|
||||||
|
|
||||||
var metadataMapOldUserMaterial map[string]interface{}
|
|
||||||
if userMaterialInfo.Metadata != nil {
|
|
||||||
err = json.Unmarshal(*userMaterialInfo.Metadata, &metadataMapOldUserMaterial)
|
|
||||||
if err != nil {
|
|
||||||
logc.Errorf(l.ctx, "userMaterialInfo Metadata Unmarshal err:%+v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var metadataChildUserMaterial = make(map[string]interface{}, 1)
|
var metadataChildUserMaterial = make(map[string]interface{}, 1)
|
||||||
metadataChildUserMaterial["merchant_category"] = req.CategoryId
|
metadataChildUserMaterial["merchant_category"] = req.CategoryId
|
||||||
metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial)
|
metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial)
|
||||||
|
@ -137,7 +136,41 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
|
||||||
}
|
}
|
||||||
|
|
||||||
var metadataChildUserInfo = make(map[string]interface{}, 1)
|
var metadataChildUserInfo = make(map[string]interface{}, 1)
|
||||||
metadataChildUserInfo["logo_selected_id"] = req.LogoSelectedId
|
|
||||||
|
_, userInfoLogoSelectedEx := metadataMapOldUserInfo["logo_selected"]
|
||||||
|
if !userInfoLogoSelectedEx {
|
||||||
|
userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"]
|
||||||
|
if !userMaterialTemplateTagEx {
|
||||||
|
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"]
|
||||||
|
if !userMaterialTemplateTagIdEx {
|
||||||
|
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{})
|
||||||
|
|
||||||
|
userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string)
|
||||||
|
|
||||||
|
userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{})
|
||||||
|
userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId]
|
||||||
|
|
||||||
|
templateTagSelected := make(map[string]interface{}, 3)
|
||||||
|
templateTagSelected["color"] = userMaterialTemplateTagIndex
|
||||||
|
templateTagSelected["template_tag"] = userMaterialTemplateIdTagId
|
||||||
|
templateTagSelected["selected_index"] = 0
|
||||||
|
|
||||||
|
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
|
||||||
|
"logo_selected_id": req.LogoSelectedId,
|
||||||
|
"template_tag_selected": templateTagSelected,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
|
||||||
|
"logo_selected_id": req.LogoSelectedId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo)
|
metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logc.Errorf(l.ctx, "userInfo Metadata SetMetadata err:%+v", err)
|
logc.Errorf(l.ctx, "userInfo Metadata SetMetadata err:%+v", err)
|
||||||
|
|
|
@ -0,0 +1,187 @@
|
||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fusenapi/model/gmodel"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
"fusenapi/utils/metadata"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/home-user-auth/internal/svc"
|
||||||
|
"fusenapi/server/home-user-auth/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logc"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserLogoTemplateTagSetLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserLogoTemplateTagSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLogoTemplateTagSetLogic {
|
||||||
|
return &UserLogoTemplateTagSetLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *UserLogoTemplateTagSetLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *UserLogoTemplateTagSetLogic) UserLogoTemplateTagSet(req *types.UserLogoTemplateTagSetReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
|
// userinfo 传入值时, 一定不为null
|
||||||
|
if userinfo.IsOnlooker() {
|
||||||
|
// 如果是,返回未授权的错误码
|
||||||
|
return resp.SetStatus(basic.CodeUnAuth)
|
||||||
|
}
|
||||||
|
if req.LogoSelectedId == 0 {
|
||||||
|
return resp.SetStatus(basic.CodeLogoSetTemplateErr, "logo logo_selected_id not null")
|
||||||
|
}
|
||||||
|
if req.TemplateTag == "" {
|
||||||
|
return resp.SetStatus(basic.CodeLogoSetTemplateErr, "logo template tag not null")
|
||||||
|
}
|
||||||
|
var userId int64
|
||||||
|
var guestId int64
|
||||||
|
NewFsUserMaterialModel := gmodel.NewFsUserMaterialModel(l.svcCtx.MysqlConn)
|
||||||
|
NewFsUserMaterialModelRow := NewFsUserMaterialModel.RowSelectBuilder(nil).Where("id = ?", req.LogoSelectedId)
|
||||||
|
|
||||||
|
if userinfo.IsGuest() {
|
||||||
|
// 如果是,使用游客ID和游客键名格式
|
||||||
|
guestId = userinfo.GuestId
|
||||||
|
NewFsUserMaterialModelRow.Where("guest_id = ?", guestId)
|
||||||
|
} else {
|
||||||
|
// 否则,使用用户ID和用户键名格式
|
||||||
|
userId = userinfo.UserId
|
||||||
|
NewFsUserMaterialModelRow.Where("user_id = ?", userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
userMaterialInfo, err := NewFsUserMaterialModel.FindOne(l.ctx, NewFsUserMaterialModelRow.Model(&gmodel.FsUserMaterial{}))
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "FsUserMaterial FindOne err:%+v", err)
|
||||||
|
return resp.SetStatus(basic.CodeLogoSetCategory, "logo not find")
|
||||||
|
}
|
||||||
|
|
||||||
|
var nowTime = time.Now().UTC()
|
||||||
|
err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
|
var metadataMapOldUserMaterial map[string]interface{}
|
||||||
|
if userMaterialInfo.Metadata != nil {
|
||||||
|
err = json.Unmarshal(*userMaterialInfo.Metadata, &metadataMapOldUserMaterial)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "userMaterialInfo Metadata Unmarshal err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var module = "profile"
|
||||||
|
|
||||||
|
var userInfo = &gmodel.FsUserInfo{}
|
||||||
|
BuilderDB := tx.Model(&gmodel.FsUserInfo{}).Where("module = ?", module)
|
||||||
|
if userId > 0 {
|
||||||
|
BuilderDB.Where("user_id=?", userId)
|
||||||
|
} else {
|
||||||
|
BuilderDB.Where("guest_id=?", guestId)
|
||||||
|
}
|
||||||
|
userInfoFirstRes := BuilderDB.First(userInfo)
|
||||||
|
err = userInfoFirstRes.Error
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
logc.Errorf(l.ctx, "userInfo First err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var metadataMapOldUserInfo map[string]interface{}
|
||||||
|
if userInfo.Metadata != nil {
|
||||||
|
err = json.Unmarshal(*userInfo.Metadata, &metadataMapOldUserInfo)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "userInfo Metadata Unmarshal err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var metadataChildUserInfo = make(map[string]interface{}, 1)
|
||||||
|
|
||||||
|
_, userInfoLogoSelectedEx := metadataMapOldUserInfo["logo_selected"]
|
||||||
|
if userInfoLogoSelectedEx {
|
||||||
|
userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"]
|
||||||
|
if !userMaterialTemplateTagEx {
|
||||||
|
logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{})
|
||||||
|
userMaterialTemplateTagIndex := userMaterialTemplateTag[req.TemplateTag]
|
||||||
|
|
||||||
|
if userMaterialTemplateTagIndex == nil {
|
||||||
|
err = errors.New("TemplateTag not find")
|
||||||
|
logc.Errorf(l.ctx, "TemplateTag not find err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
templateTagSelected := make(map[string]interface{}, 3)
|
||||||
|
templateTagSelected["color"] = userMaterialTemplateTagIndex
|
||||||
|
templateTagSelected["template_tag"] = req.TemplateTag
|
||||||
|
templateTagSelected["selected_index"] = req.TemplateTagColorIndex
|
||||||
|
|
||||||
|
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
|
||||||
|
"template_tag_selected": templateTagSelected,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "userInfo Metadata SetMetadata err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
metadataBUserInfo, err := json.Marshal(metadataMapUserInfo)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "userInfo Metadata marshal err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userInfo.Metadata = &metadataBUserInfo
|
||||||
|
|
||||||
|
if userInfo.Id == 0 {
|
||||||
|
// 新增
|
||||||
|
userInfo.Module = &module
|
||||||
|
userInfo.Ctime = &nowTime
|
||||||
|
userInfo.Utime = &nowTime
|
||||||
|
userInfo.UserId = &userId
|
||||||
|
userInfo.GuestId = &guestId
|
||||||
|
resCreate := tx.Model(&userInfo).Create(&userInfo)
|
||||||
|
err = resCreate.Error
|
||||||
|
} else {
|
||||||
|
// 更新
|
||||||
|
userInfo.Utime = &nowTime
|
||||||
|
resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo)
|
||||||
|
err = resUpdates.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if err != gorm.ErrRecordNotFound {
|
||||||
|
logc.Errorf(l.ctx, "FsUserInfo Updates err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatus(basic.CodeDbSqlErr, "set logo fail")
|
||||||
|
}
|
||||||
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *UserLogoTemplateTagSetLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
|
@ -5,6 +5,12 @@ import (
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type UserLogoTemplateTagSetReq struct {
|
||||||
|
LogoSelectedId int64 `form:"logo_selected_id"`
|
||||||
|
TemplateTag string `form:"template_tag"`
|
||||||
|
TemplateTagColorIndex int64 `form:"template_tag_color_index"`
|
||||||
|
}
|
||||||
|
|
||||||
type UserLogoSetReq struct {
|
type UserLogoSetReq struct {
|
||||||
SetLogoSelected int64 `form:"set_logo_selected"`
|
SetLogoSelected int64 `form:"set_logo_selected"`
|
||||||
LogoSelectedId int64 `form:"logo_selected_id"`
|
LogoSelectedId int64 `form:"logo_selected_id"`
|
||||||
|
|
|
@ -20,6 +20,7 @@ AWS:
|
||||||
Token:
|
Token:
|
||||||
BLMService:
|
BLMService:
|
||||||
Url: "http://18.119.109.254:8999"
|
Url: "http://18.119.109.254:8999"
|
||||||
|
# Url: "http://192.168.1.9:8999"
|
||||||
ImageProcess:
|
ImageProcess:
|
||||||
# Url: "http://192.168.1.7:8999/FeatureExtraction"
|
# Url: "http://192.168.1.7:8999/FeatureExtraction"
|
||||||
Url: "http://18.119.109.254:8999/FeatureExtraction"
|
Url: "http://18.119.109.254:8999/FeatureExtraction"
|
||||||
|
|
|
@ -71,8 +71,20 @@ service home-user-auth {
|
||||||
// 用户logo设置当前
|
// 用户logo设置当前
|
||||||
@handler UserLogoSetHandler
|
@handler UserLogoSetHandler
|
||||||
post /api/user/logo-set (UserLogoSetReq) returns (response);
|
post /api/user/logo-set (UserLogoSetReq) returns (response);
|
||||||
|
|
||||||
|
// 用户logo模版信息
|
||||||
|
@handler UserLogoTemplateTagSetHandler
|
||||||
|
post /api/user/logo-templatetag-set (UserLogoTemplateTagSetReq) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
UserLogoTemplateTagSetReq {
|
||||||
|
LogoSelectedId int64 `form:"logo_selected_id"`
|
||||||
|
TemplateTag string `form:"template_tag"`
|
||||||
|
TemplateTagColorIndex int64 `form:"template_tag_color_index"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
UserLogoSetReq {
|
UserLogoSetReq {
|
||||||
SetLogoSelected int64 `form:"set_logo_selected"`
|
SetLogoSelected int64 `form:"set_logo_selected"`
|
||||||
|
|
|
@ -54,8 +54,16 @@ type (
|
||||||
GuestId int64 `json:"guest_id"`
|
GuestId int64 `json:"guest_id"`
|
||||||
}
|
}
|
||||||
LogoInfoRes struct {
|
LogoInfoRes struct {
|
||||||
Metadata *string `json:"metadata"`
|
Metadata *string `json:"metadata"`
|
||||||
LogoUrl *string `json:"logo_url"`
|
LogoUrl *string `json:"logo_url"`
|
||||||
|
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"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,28 +92,36 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
|
||||||
}
|
}
|
||||||
var userMaterialInfo gmodel.FsUserMaterial
|
var userMaterialInfo gmodel.FsUserMaterial
|
||||||
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
|
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"`
|
||||||
|
}
|
||||||
if userInfo.Id == 0 {
|
if userInfo.Id == 0 {
|
||||||
userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
|
userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
|
||||||
if err != gorm.ErrRecordNotFound {
|
if err != gorm.ErrRecordNotFound {
|
||||||
logc.Errorf(ctx, "FsUserMaterial FindLatestOne err:%+v", err)
|
logc.Errorf(ctx, "FsUserMaterial FindLatestOne err:%+v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// var userMaterialInfoMetadata map[string]interface{}
|
||||||
} else {
|
} else {
|
||||||
if userInfo.Metadata != nil {
|
if userInfo.Metadata != nil {
|
||||||
var metadata map[string]interface{}
|
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo)
|
||||||
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadata)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logc.Errorf(ctx, "userInfo.Metadata Unmarshal err:%+v", err)
|
logc.Errorf(ctx, "userInfo.Metadata Unmarshal err:%+v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
logoSelectedId, isEx := metadata["logo_selected_id"]
|
|
||||||
if isEx {
|
if metadataUserInfo.LogoSelected.LogoSelectedId != 0 {
|
||||||
var materialId int64 = int64(logoSelectedId.(float64))
|
userMaterialInfos, err := userMaterialModel.FindOneById(ctx, metadataUserInfo.LogoSelected.LogoSelectedId)
|
||||||
userMaterialInfos, err := userMaterialModel.FindOneById(ctx, materialId)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != gorm.ErrRecordNotFound {
|
if err != gorm.ErrRecordNotFound {
|
||||||
logc.Errorf(ctx, "FsUserInfo First err:%+v", err)
|
logc.Errorf(ctx, "userMaterial findOneById err:%+v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,8 +150,9 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo
|
||||||
logoUrl = userMaterialInfo.ResourceUrl
|
logoUrl = userMaterialInfo.ResourceUrl
|
||||||
}
|
}
|
||||||
return &LogoInfoRes{
|
return &LogoInfoRes{
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
LogoUrl: logoUrl,
|
LogoUrl: logoUrl,
|
||||||
|
LogoSelected: metadataUserInfo.LogoSelected,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +319,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
||||||
combineParam["phone"] = in.Phone
|
combineParam["phone"] = in.Phone
|
||||||
combineParam["address"] = in.Address
|
combineParam["address"] = in.Address
|
||||||
combineParam["qrcode"] = in.Qrcode
|
combineParam["qrcode"] = in.Qrcode
|
||||||
|
combineParam["template_tag_selected"] = resLogoInfo.LogoSelected
|
||||||
|
|
||||||
var postMap = make(map[string]interface{}, 2)
|
var postMap = make(map[string]interface{}, 2)
|
||||||
postMap["module_data"] = moduleDataMap
|
postMap["module_data"] = moduleDataMap
|
||||||
|
|
|
@ -99,6 +99,8 @@ var (
|
||||||
|
|
||||||
CodeLogoCombineErr = &StatusResponse{5115, "logo combine fail"} // 合图失败
|
CodeLogoCombineErr = &StatusResponse{5115, "logo combine fail"} // 合图失败
|
||||||
CodeLogoCombineNoFoundErr = &StatusResponse{5116, "template record not found"} // 模版不存在
|
CodeLogoCombineNoFoundErr = &StatusResponse{5116, "template record not found"} // 模版不存在
|
||||||
|
|
||||||
|
CodeLogoSetTemplateErr = &StatusResponse{5117, "logo set template fail"} // 设置模版标签失败
|
||||||
)
|
)
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
|
|
|
@ -14,15 +14,9 @@ func TestCase1(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen")
|
conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen")
|
||||||
err := fssql.MetadataModulePATCH(conn, "logo", gmodel.FsChangeCode{}, u, "id = ?", 6)
|
err := fssql.MetadataModulePATCH(conn, "profile", gmodel.FsUserInfo{}, u, "id = ?", 90)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fssql.MetadataResourcePATCH(conn,
|
|
||||||
"f8932c0379fa5aa3397dc0a963696ca90536cc273ea10119b0137fd15ecfe673", u)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,15 @@ func SetMetadata(metadataChild map[string]interface{}, oldMetadata map[string]in
|
||||||
for k, v := range metadataChild {
|
for k, v := range metadataChild {
|
||||||
switch val := v.(type) {
|
switch val := v.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
oldResourceMetadataData := oldMetadata[k].(map[string]interface{})
|
kValue, kEx := oldMetadata[k]
|
||||||
for key, val1 := range val {
|
var oldResourceMetadataData map[string]interface{}
|
||||||
oldResourceMetadataData[key] = val1
|
if kEx {
|
||||||
|
oldResourceMetadataData = kValue.(map[string]interface{})
|
||||||
|
} else {
|
||||||
|
oldResourceMetadataData = make(map[string]interface{}, len(val))
|
||||||
|
}
|
||||||
|
for key1, val1 := range val {
|
||||||
|
oldResourceMetadataData[key1] = val1
|
||||||
}
|
}
|
||||||
oldMetadata[k] = oldResourceMetadataData
|
oldMetadata[k] = oldResourceMetadataData
|
||||||
default:
|
default:
|
||||||
|
@ -20,11 +26,17 @@ func SetMetadata(metadataChild map[string]interface{}, oldMetadata map[string]in
|
||||||
for k, v := range metadataChild {
|
for k, v := range metadataChild {
|
||||||
switch val := v.(type) {
|
switch val := v.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
var resourceMetadataData = make(map[string]interface{}, len(val))
|
kValue, kEx := oldMetadata[k]
|
||||||
for key, val1 := range val {
|
var oldResourceMetadataData map[string]interface{}
|
||||||
resourceMetadataData[key] = val1
|
if kEx {
|
||||||
|
oldResourceMetadataData = kValue.(map[string]interface{})
|
||||||
|
} else {
|
||||||
|
oldResourceMetadataData = make(map[string]interface{}, len(val))
|
||||||
}
|
}
|
||||||
oldMetadata[k] = resourceMetadataData
|
for key, val1 := range val {
|
||||||
|
oldResourceMetadataData[key] = val1
|
||||||
|
}
|
||||||
|
oldMetadata[k] = oldResourceMetadataData
|
||||||
default:
|
default:
|
||||||
oldMetadata[k] = val
|
oldMetadata[k] = val
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user