1.修改basedo字段类型
2、提供获取authen中用户信息的方法
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
"github.com/gogf/gf/v2/database/gredis"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/tiger1103/gfast-token/gftoken"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
@@ -51,3 +57,20 @@ func GetMonthToday(t time.Time, month int) time.Time {
|
||||
}
|
||||
return target.AddDate(0, 0, t.Day()-1)
|
||||
}
|
||||
func GetUserInfo(ctx context.Context) (user do.User, err error) {
|
||||
redisAddr := g.Cfg().MustGet(ctx, "redis.default.address").String()
|
||||
gft := gftoken.NewGfToken(
|
||||
gftoken.WithCacheKey("gfToken:"),
|
||||
gftoken.WithTimeout(20),
|
||||
gftoken.WithMaxRefresh(10),
|
||||
gftoken.WithMultiLogin(true),
|
||||
//gftoken.WithExcludePaths(g.SliceStr{"/excludeDemo"}),
|
||||
gftoken.WithGRedisConfig(&gredis.Config{
|
||||
Address: redisAddr,
|
||||
Db: 1,
|
||||
}))
|
||||
data, _ := gft.ParseToken(g.RequestFromCtx(ctx))
|
||||
user.Id = gconv.Map(data.Data)["id"]
|
||||
user.TenantId = gconv.Map(data.Data)["tenantId"]
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user