business

package
v0.0.0-...-36e0f04 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(data interface{}, secret string, extras ...map[string]interface{}) (string, error)

GenerateJWT 生成通用 JWT。 data: 任意结构体或 map,将被放入 payload。 secret: 签名密钥。 extras(可选): 附加的 claims map[string]interface{},用于添加或覆盖字段。

func ParseJWT

func ParseJWT(tokenString string, secret string) (map[string]interface{}, error)

ParseJWT 解析并验证 JWT,返回载荷 map

Types

type LoginReq

type LoginReq struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Serv

type Serv struct {
	Db  *mongo.Database
	Cfg *goconfig.ConfigFile
	// contains filtered or unexported fields
}

func New

func New(url, dbname string) (*Serv, error)

func (*Serv) GetApiName

func (s *Serv) GetApiName() string

func (*Serv) GetToken

func (s *Serv) GetToken(ctx context.Context, jwtStr string) (kratos.Token, error)

func (*Serv) GetUserInfo

func (s *Serv) GetUserInfo(ctx context.Context, token kratos.Token, buffer []byte, query map[string]string) (interface{}, error)

func (*Serv) Login

func (s *Serv) Login(ctx context.Context, token kratos.Token, buffer []byte, query map[string]string) (interface{}, error)

func (*Serv) MongoClient

func (s *Serv) MongoClient() *mongo.Client

func (*Serv) QueryTime

func (s *Serv) QueryTime(start, end string) (bson.M, error)

func (*Serv) QueryValue

func (s *Serv) QueryValue(data bson.M, query map[string]string, key string) bson.M

func (*Serv) SessionName

func (s *Serv) SessionName() string

func (*Serv) Start

func (s *Serv) Start(addr string, router *httprouter.Router) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL