Documentation ¶
Index ¶
- Variables
- func ArrayToString(array []interface{}) string
- func BcryptCheck(password, hash string) bool
- func BcryptHash(password string) string
- func Contains[T comparable](slice []T, item T) bool
- func CreateDir(dirs ...string) (err error)
- func DeLFile(filePath string) error
- func Eq(mark string) string
- func FileExist(path string) bool
- func FileMove(src string, dst string) (err error)
- func FirstLower(s string) string
- func FirstUpper(s string) string
- func Ge(mark string) string
- func GetStringWithTime(src string) string
- func Gt(mark string) string
- func IsValidPassword(password string) bool
- func Le(mark string) string
- func Lt(mark string) string
- func MD5V(str []byte, b ...byte) string
- func MaheHump(s string) string
- func Ne(mark string) string
- func NewSnowflakeWorker(workerId int64) *worker
- func NotEmpty() string
- func ParseDuration(d string) (time.Duration, error)
- func PathExists(path string) (bool, error)
- func Pointer[T any](in T) (out *T)
- func RandomInt(min, max int) int
- func RandomString(n int) string
- func RegexpMatch(rule string) string
- func RegisterRule(key string, rule Rules) (err error)
- func StructToMap(obj interface{}) map[string]interface{}
- func TrimSpace(target interface{})
- func Verify(st interface{}, roleMap Rules) (err error)
- type BaseClaims
- type CustomClaims
- type JWT
- type Rules
- type RulesMap
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenExpired = errors.New("令牌超时") ErrTokenNotValidYet = errors.New("令牌尚未生效") ErrTokenMalformed = errors.New("非法令牌") ErrTokenInvalid = errors.New("无处理令牌") ErrTokenTypeError = errors.New("令牌类型转换错误") )
View Source
var ( IdVerify = Rules{"ID": []string{NotEmpty()}} ApiVerify = Rules{"Path": {NotEmpty()}, "Description": {NotEmpty()}, "ApiGroup": {NotEmpty()}, "Method": {NotEmpty()}} MenuVerify = Rules{"Path": {NotEmpty()}, "ParentId": {NotEmpty()}, "Name": {NotEmpty()}, "Component": {NotEmpty()}, "Sort": {Ge("0")}} MenuMetaVerify = Rules{"Title": {NotEmpty()}} LoginVerify = Rules{"Secret": {NotEmpty()}} RegisterVerify = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}} PageInfoVerify = Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}} CustomerVerify = Rules{"CustomerName": {NotEmpty()}, "CustomerPhoneData": {NotEmpty()}} AutoCodeVerify = Rules{"Abbreviation": {NotEmpty()}, "StructName": {NotEmpty()}, "PackageName": {NotEmpty()}, "Fields": {NotEmpty()}} AutoPackageVerify = Rules{"PackageName": {NotEmpty()}} AuthorityVerify = Rules{"AuthorityId": {NotEmpty()}, "AuthorityName": {NotEmpty()}} AuthorityIdVerify = Rules{"AuthorityId": {NotEmpty()}} OldAuthorityVerify = Rules{"OldAuthorityId": {NotEmpty()}} ChangePasswordVerify = Rules{"Password": {NotEmpty()}, "NewPassword": {NotEmpty()}} SetUserAuthorityVerify = Rules{"AuthorityId": {NotEmpty()}} )
View Source
var CustomizeMap = make(map[string]Rules)
Functions ¶
func ArrayToString ¶
func ArrayToString(array []interface{}) string
func FirstLower ¶
func FirstUpper ¶
func GetStringWithTime ¶
func NewSnowflakeWorker ¶
func NewSnowflakeWorker(workerId int64) *worker
func PathExists ¶
func RegexpMatch ¶
func RegisterRule ¶
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
Types ¶
type BaseClaims ¶
type CustomClaims ¶
type CustomClaims struct { BaseClaims BufferTime int64 jwt.RegisteredClaims }
type JWT ¶
type JWT struct { SigningKey []byte SingleflightGroup *singleflight.Group }
func (*JWT) CreateClaims ¶
func (j *JWT) CreateClaims(baseClaims BaseClaims) CustomClaims
func (*JWT) CreateTokenByOldToken ¶
func (j *JWT) CreateTokenByOldToken(oldToken string, claims CustomClaims) (string, error)
根据旧token创建新token
Source Files ¶
Click to show internal directories.
Click to hide internal directories.