utils

package
v0.0.0-...-15e837a Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var URLMapping = map[string]string{
	"gpt": constant.GPTBaseURL,
	"glm": constant.GLMBaseURL,
}

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hashedPassword string) error

CheckPasswordHash 验证密码是否正确

func GenerateID

func GenerateID() int64

func GenerateToken

func GenerateToken(userID int64) (string, error)

GenerateToken 生成 JWT

func GetBaseURL

func GetBaseURL(model string) (string, error)

GetBaseURL 根据关键字模糊匹配并返回对应的 BaseURL

func GetUserIDFromContext

func GetUserIDFromContext(c *gin.Context) int64

GetUserIDFromContext 从上下文中获取用户 ID

func HashPassword

func HashPassword(password string) (string, error)

HashPassword 哈希密码

func JSONError

func JSONError(c *gin.Context, code int, err error)

func ParseToken

func ParseToken(tokenStr string) (jwt.MapClaims, error)

ParseToken 解析 JWT

Types

This section is empty.

Jump to

Keyboard shortcuts

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