fix
This commit is contained in:
parent
56f4460995
commit
12c9732fa8
|
@ -62,7 +62,7 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
|
|||
}
|
||||
|
||||
rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where user_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname)
|
||||
err := m.db.Raw(rawsql, userId).Take(&baseinfo).Error
|
||||
err := m.db.WithContext(ctx).Raw(rawsql, userId).Take(&baseinfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -87,3 +87,32 @@ func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int
|
|||
}
|
||||
return resp, err
|
||||
}
|
||||
func (m *FsUserInfoModel) GetProfileByUserIdGuestId(ctx context.Context, pkey string, userId, guestId int64) (map[string]any, error) {
|
||||
|
||||
var baseinfo map[string]any
|
||||
tname := fssql.GetGormTableName(m.db, FsUserInfo{})
|
||||
|
||||
if pkey == "." {
|
||||
pkey = ""
|
||||
} else {
|
||||
pkey = "." + pkey
|
||||
}
|
||||
|
||||
rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where user_id = ? and guest_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname)
|
||||
err := m.db.WithContext(ctx).Raw(rawsql, userId, guestId).Take(&baseinfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v, ok := baseinfo["query"].(string)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var info map[string]any
|
||||
err = json.Unmarshal([]byte(v), &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"fusenapi/utils/s3url_to_s3id"
|
||||
"fusenapi/utils/template_switch_info"
|
||||
"gorm.io/gorm"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"context"
|
||||
|
@ -343,6 +344,22 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR
|
|||
if req.SelectedColorIndex < 0 {
|
||||
return types.TemplateTagColorInfo{}, errors.New("param selected_color_index is invalid")
|
||||
}
|
||||
if req.Logo == "" {
|
||||
//颜色选择置0
|
||||
req.SelectedColorIndex = 0
|
||||
//获取默认profile从中获取logo
|
||||
profile, err := l.svcCtx.AllModels.FsUserInfo.GetProfileByUserIdGuestId(l.ctx, "logo_selected.logo_url", 0, 0)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return types.TemplateTagColorInfo{}, errors.New("the default profile info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return types.TemplateTagColorInfo{}, errors.New("failed to get default profile info for without logo")
|
||||
}
|
||||
if profile["logo_url"] != nil && reflect.TypeOf(profile["logo_url"]).String() == "string" {
|
||||
req.Logo = profile["logo_url"].(string)
|
||||
}
|
||||
}
|
||||
//根据logo查询素材资源
|
||||
resourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo)
|
||||
if resourceId == "" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user