info
This commit is contained in:
parent
c82ae399b7
commit
730491ffed
@ -6,7 +6,6 @@ import (
|
|||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/check"
|
"fusenapi/utils/check"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
@ -203,10 +202,9 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r
|
|||||||
if v, ok := metadict["userinfo.profile"]; ok {
|
if v, ok := metadict["userinfo.profile"]; ok {
|
||||||
|
|
||||||
if v == nil {
|
if v == nil {
|
||||||
|
|
||||||
info := QueryDefault(l.svcCtx.MysqlConn, "profile", "logo_selected", "fs_user_info")
|
info := QueryDefault(l.svcCtx.MysqlConn, "profile", "logo_selected", "fs_user_info")
|
||||||
log.Println(info)
|
|
||||||
metadict["userinfo.profile"] = info
|
metadict["userinfo.profile"] = info
|
||||||
// log.Println(metadict)
|
|
||||||
} else {
|
} else {
|
||||||
profileDict := v.(map[string]any)
|
profileDict := v.(map[string]any)
|
||||||
if _, ok := profileDict["logo_selected"]; !ok {
|
if _, ok := profileDict["logo_selected"]; !ok {
|
||||||
@ -220,11 +218,49 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r
|
|||||||
info := QueryDefault(l.svcCtx.MysqlConn, "profile", "logo_selected", "fs_user_info")
|
info := QueryDefault(l.svcCtx.MysqlConn, "profile", "logo_selected", "fs_user_info")
|
||||||
metadict["userinfo.profile.logo_selected"] = info
|
metadict["userinfo.profile.logo_selected"] = info
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var info map[string]any
|
||||||
|
for k, v := range metadict {
|
||||||
|
if v == nil {
|
||||||
|
if strings.HasPrefix(k, "userinfo.profile.logo_selected") {
|
||||||
|
if info == nil {
|
||||||
|
info = QueryDefault(l.svcCtx.MysqlConn, "profile", "logo_selected", "fs_user_info")
|
||||||
|
}
|
||||||
|
|
||||||
|
curValue, err := GetMapValueByKey(info, strings.Split(k, ".")[2:])
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
continue
|
||||||
|
// return resp.SetStatus(basic.CodeOK, metadict)
|
||||||
|
}
|
||||||
|
metadict[k] = curValue
|
||||||
|
// curValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK, metadict)
|
return resp.SetStatus(basic.CodeOK, metadict)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetMapValueByKey(info map[string]interface{}, keys []string) (interface{}, error) {
|
||||||
|
// keys := strings.Split(key, ".")[2:]
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
if cur, ok := info[k]; ok {
|
||||||
|
if curMap, ok := cur.(map[string]interface{}); ok {
|
||||||
|
info = curMap
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("keys is not exists %#v", keys)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("keys is not exists %#v", keys)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return info, nil
|
||||||
|
}
|
||||||
|
|
||||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
// func (l *InfoLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
// func (l *InfoLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user