package param import ( "context" "encoding/json" ) // GetUserID 为userid func GetUserID(c context.Context) int64 { userID := c.Value("user_id") if _, ok := userID.(int64); ok { return userID.(int64) } return 0 } func GetAccountID(c context.Context) int64 { accountID := c.Value("account_id") if _, ok := accountID.(int64); ok { return accountID.(int64) } return 0 } func GetAuthToken(c context.Context) string { token := c.Value("token") if _, ok := token.(string); ok { return token.(string) } return "" } func GetJwtClaims(c context.Context) json.RawMessage { claim := c.Value("claim") if _, ok := claim.(json.RawMessage); ok { return claim.(json.RawMessage) } return []byte{} }