From 963940c367f0101d328029ee58612348bbabe334 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 24 Nov 2023 11:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gmodel/fs_user_info_logic.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/model/gmodel/fs_user_info_logic.go b/model/gmodel/fs_user_info_logic.go index 17ba0982..f2667011 100644 --- a/model/gmodel/fs_user_info_logic.go +++ b/model/gmodel/fs_user_info_logic.go @@ -9,6 +9,7 @@ import ( "fusenapi/utils/fssql" "fusenapi/utils/handlers" + "github.com/tidwall/gjson" "gorm.io/gorm" ) @@ -113,26 +114,18 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in return m.getDefaultProfile(ctx, tname) } - if logoSelected, ok := info["logo_selected"]; ok { - if version, ok := logoSelected.(map[string]any)["version"]; ok { - if ver, ok := version.(string); ok { - if ver != versionML { - defaultUserInfo, err := m.getDefaultProfile(ctx, tname) - if err != nil { - return nil, err - } - info["logo_selected"] = defaultUserInfo["logo_selected"] - } - } + if logoSelected := gjson.Get(v, "logo_selected"); logoSelected.Exists() { + if ver := logoSelected.Get("version"); ver.Exists() && ver.String() == versionML { + return info, nil } - } else { - defaultUserInfo, err := m.getDefaultProfile(ctx, tname) - if err != nil { - return nil, err - } - info["logo_selected"] = defaultUserInfo["logo_selected"] } + defaultUserInfo, err := m.getDefaultProfile(ctx, tname) + if err != nil { + return nil, err + } + info["logo_selected"] = defaultUserInfo["logo_selected"] + return info, nil }