package svc import ( "applet/app/lib/auth" "applet/app/md" "applet/app/utils/cache" "applet/app/utils/logx" "code.fnuoos.com/zhimeng/model.git/src/model" ) func HandleLoginToken(cacheKey string, admin *model.Agent) (string, error) { // 获取之前生成的token token, err := cache.GetString(cacheKey) if err != nil { _ = logx.Error(err) } // 没有获取到 if err != nil || token == "" { // 生成token token, err = auth.GenToken(admin.Id, admin.Username) if err != nil { return "", err } // 缓存token _, err = cache.SetEx(cacheKey, token, md.JwtTokenCacheTime) if err != nil { return "", err } return token, nil } return token, nil }