utils

package
v0.0.0-...-3a3bdc2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBsonTimeToString

func ConvertBsonTimeToString(dateTime bson.DateTime) string

func ConvertByteHashToString

func ConvertByteHashToString(hash []byte) string

ConvertByteHashToString 将 byte 类型的哈希转换为字符串哈希

func ConvertStringHashToByte

func ConvertStringHashToByte(hash string) []byte

ConvertStringHashToByte 将字符串哈希转换为 byte 类型的哈希

func ConvertStringToOrdered

func ConvertStringToOrdered[T constraints.Ordered](s string, v *T) error

ConvertStringToOrdered 将字符串转换为指定类型的值

func Crypt

func Crypt(password string) (string, error)

Crypt Encrypt the password using crypto/bcrypt

func EnvInit

func EnvInit()

func ErrResp

func ErrResp(c *app.RequestContext, err error)

func GetSHA256Byte

func GetSHA256Byte(data string) []byte

func GetSHA256String

func GetSHA256String(data string) string

func LoadEnvFile

func LoadEnvFile(fileName string)

LoadEnvFile please put env file in /envs directory before using this func

func MillTimeStampToTime

func MillTimeStampToTime(timestamp int64) time.Time

MillTimeStampToTime convert ms timestamp to time.Time

func NewFileName

func NewFileName(user_id, time int64) string

NewFileName Splicing user_id and time to make unique filename

func SecondTimeStampToTime

func SecondTimeStampToTime(timestamp int64) time.Time

SecondTimeStampToTime convert s timestamp to time.Time

func URLconvert

func URLconvert(ctx context.Context, c *app.RequestContext, path string) (fullURL string)

URLconvert Convert the path in the database into a complete url accessible by the front end

func UrlConvertReverse

func UrlConvertReverse(ctx context.Context, fullURL string) (path string)

UrlConvertReverse 从完整URL还原数据库中存储的相对路径

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword 验证密码,长度至少8位,并且包含字母和数字

func VerifyPassword

func VerifyPassword(password, hashedPassword string) bool

VerifyPassword Verify the password is consistent with the hashed password in the database

Types

type BaseResp

type BaseResp struct {
	StatusCode int32
	StatusMsg  string
}

func BuildBaseResp

func BuildBaseResp(err error) *BaseResp

BuildBaseResp convert error and build BaseResp

Jump to

Keyboard shortcuts

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