tools

package
v0.5.17 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SystemErr    = 500
	MySqlErr     = 501
	LdapErr      = 505
	OperationErr = 506
	ValidatorErr = 412
)

Variables

View Source
var VerificationCodeCache = cache.New(24*time.Hour, 48*time.Hour)

验证码放到缓存当中

Functions

func ArrStrCmp

func ArrStrCmp(src []string, dest []string) ([]string, []string)

字符串切片比较

func ArrUintCmp

func ArrUintCmp(src []uint, dest []uint) ([]uint, []uint)

uint切片比较

func ConvertToPinYin added in v0.5.1

func ConvertToPinYin(src string) (dst string)

func DecodeStrFromBase64

func DecodeStrFromBase64(str string) string

解密base64字符串

func EncodePass added in v0.5.11

func EncodePass(rawPassPhrase []byte) string

Encode encodes the []byte of raw password

func EncodeStr2Base64

func EncodeStr2Base64(str string) string

加密base64字符串

func Err

func Err(c *gin.Context, err *RspError, data interface{})

Err http 错误

func Json2Struct

func Json2Struct(str string, obj interface{})

json转为结构体

func JsonI2Struct

func JsonI2Struct(str interface{}, obj interface{})

json interface转为结构体

func JsonToMap added in v0.5.0

func JsonToMap(jsonStr string) (m map[string]string, err error)

Convert json string to map

func MapToJson added in v0.5.0

func MapToJson(m map[string]string) (string, error)

Convert map to json string

func Matches added in v0.5.11

func Matches(encodedPassPhrase, rawPassPhrase []byte) bool

Matches matches the encoded password and the raw password

func NewGenPasswd

func NewGenPasswd(passwd string) string

密码加密

func NewParPasswd

func NewParPasswd(passwd string) string

密码解密

func RSADecrypt

func RSADecrypt(base64Data, privateBytes []byte) ([]byte, error)

对数据进行解密操作

func RSAEncrypt

func RSAEncrypt(data, publicBytes []byte) ([]byte, error)

RSA加密

func Response

func Response(c *gin.Context, httpStatus int, code int, data gin.H, message string)

返回前端

func SendCode added in v0.5.8

func SendCode(sendto []string) error

SendCode 发送验证码

func SendMail

func SendMail(sendto []string, pass string) error

func SliceToString

func SliceToString(src []uint, delim string) string

将字符串切片转换为uint切片

func StringToSlice

func StringToSlice(src string, delim string) []uint

将字符串切片转换为uint切片

func Struct2Json

func Struct2Json(obj interface{}) string

结构体转为json

func Success

func Success(c *gin.Context, data interface{})

Success http 成功

Types

type H

type H map[string]interface{}

H is a shortcut for map[string]interface{}

type PageOption

type PageOption struct {
	PageNum  int `json:"pageNum"`
	PageSize int `json:"pageSize"`
}

func NewPageOption

func NewPageOption(pageNum, pageSize int) *PageOption

NewPageOption 创建一个分页参数

type RspError

type RspError struct {
	// contains filtered or unexported fields
}

func NewLdapError

func NewLdapError(err error) *RspError

NewLdapError ldap错误

func NewMySqlError

func NewMySqlError(err error) *RspError

NewMySqlError mysql错误

func NewOperationError

func NewOperationError(err error) *RspError

NewOperationError 操作错误

func NewRspError

func NewRspError(code int, err error) *RspError

NewRspError New

func NewValidatorError

func NewValidatorError(err error) *RspError

NewValidatorError 验证错误

func ReloadErr

func ReloadErr(err interface{}) *RspError

ReloadErr 重新加载错误

func (*RspError) Code

func (re *RspError) Code() int

func (*RspError) Error

func (re *RspError) Error() string

Jump to

Keyboard shortcuts

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