Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayToString(array []interface{}) string
- func AutoClearCode(filepath string, codeData string) error
- func AutoInjectionCode(filepath string, funcName string, codeData string) error
- func BcryptCheck(password, hash string) bool
- func BcryptHash(password string) string
- func BreakPointContinue(content []byte, fileName string, contentNumber int, contentTotal int, ...) (string, error)
- func CheckMd5(content []byte, chunkMd5 string) (CanUpload bool)
- func ClearTable(db *gorm.DB, tableName string, compareField string, interval string) error
- 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 GetClaims(c *gin.Context) (*systemReq.CustomClaims, error)
- func GetUserAuthorityId(c *gin.Context) uint
- func GetUserID(c *gin.Context) uint
- func GetUserInfo(c *gin.Context) *systemReq.CustomClaims
- func GetUserName(c *gin.Context) string
- func GetUserUuid(c *gin.Context) string
- func Gt(mark string) string
- func Le(mark string) string
- func Lt(mark string) string
- func MD5V(str []byte, b ...byte) string
- func MaheHump(s string) string
- func MakeFile(fileName string, FileMd5 string) (string, error)
- func Ne(mark string) string
- 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 RegexpMatch(rule string) string
- func RegisterRule(key string, rule Rules) (err error)
- func Reload() error
- func RemoveChunk(FileMd5 string) error
- func StructToMap(obj interface{}) map[string]interface{}
- func TrimSpace(target interface{})
- func Unzip(zipFile string, destDir string) ([]string, error)
- func Verify(st interface{}, roleMap Rules) (err error)
- func ZipFiles(filename string, files []string, oldForm, newForm string) error
- type Cpu
- type Disk
- type JWT
- func (j *JWT) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims
- func (j *JWT) CreateToken(claims request.CustomClaims) (string, error)
- func (j *JWT) CreateTokenByOldToken(oldToken string, claims request.CustomClaims) (string, error)
- func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error)
- type Os
- type Ram
- type Rules
- type RulesMap
- type Server
Constants ¶
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
Variables ¶
var ( TokenExpired = errors.New("Token is expired") TokenNotValidYet = errors.New("Token not active yet") TokenMalformed = errors.New("That's not even a token") TokenInvalid = errors.New("Couldn't handle this token:") )
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()}} EmailLoginVerify = Rules{"Email": {NotEmpty()}, "Password": {NotEmpty()}} LoginVerify = Rules{"CaptchaId": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {NotEmpty()}} LoginWithoutCaptchaVerify = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}} RegisterVerify = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}} ForgotPasswordVerify = Rules{"Phone": {NotEmpty()}, "Password": {NotEmpty()}, "SmsCode": {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()}} )
var CustomizeMap = make(map[string]Rules)
Functions ¶
func ArrayToString ¶
func ArrayToString(array []interface{}) string
func AutoClearCode ¶
func AutoInjectionCode ¶
func BreakPointContinue ¶
func ClearTable ¶
func Eq ¶
@function: Eq @description: 等于入参(==) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较 @param: mark string @return: string
func FirstLower ¶
func FirstUpper ¶
func Ge ¶
@function: Ge @description: 大于等于入参(>=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较 @param: mark string @return: string
func GetUserAuthorityId ¶
GetUserAuthorityId 从Gin的Context中获取从jwt解析出来的用户角色id
func GetUserInfo ¶
func GetUserInfo(c *gin.Context) *systemReq.CustomClaims
GetUserInfo 从Gin的Context中获取从jwt解析出来的用户角色id
func GetUserUuid ¶
GetUserUuid 从Gin的Context中获取从jwt解析出来的用户UUID
func Gt ¶
@function: Gt @description: 大于入参(>) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较 @param: mark string @return: string
func Le ¶
@function: Le @description: 小于等于入参(<=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较 @param: mark string @return: string
func Lt ¶
@function: Lt @description: 小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较 @param: mark string @return: string
func Ne ¶
@function: Ne @description: 不等于入参(!=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较 @param: mark string @return: string
func NotEmpty ¶
func NotEmpty() string
@function: NotEmpty @description: 非空 不能为其对应类型的0值 @return: string
func PathExists ¶
func RegexpMatch ¶
@author: [zooqkl](https://github.com/zooqkl) @function: RegexpMatch @description: 正则校验 校验输入项是否满足正则表达式 @param: rule string @return: string
func RegisterRule ¶
@function: RegisterRule @description: 注册自定义规则方案建议在路由初始化层即注册 @param: key string, rule Rules @return: err error
func RemoveChunk ¶
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
Types ¶
type Disk ¶
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateClaims ¶
func (j *JWT) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims request.CustomClaims) (string, error)
CreateToken 创建一个token
func (*JWT) CreateTokenByOldToken ¶
CreateTokenByOldToken 旧token 换新token 使用归并回源避免并发问题
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error)
ParseToken 解析 token