utils

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigEnv  = "GVA_CONFIG"
	ConfigFile = "config.yaml"
)

全局常量

Variables

View Source
var (
	IdVerify               = Rules{"ID": {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{"CaptchaId": {NotEmpty()}, "Captcha": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {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()}}
	AuthorityVerify        = Rules{"AuthorityId": {NotEmpty()}, "AuthorityName": {NotEmpty()}, "ParentId": {NotEmpty()}}
	AuthorityIdVerify      = Rules{"AuthorityId": {NotEmpty()}}
	OldAuthorityVerify     = Rules{"OldAuthorityId": {NotEmpty()}}
	ChangePasswordVerify   = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}, "NewPassword": {NotEmpty()}}
	SetUserAuthorityVerify = Rules{"UUID": {NotEmpty()}, "AuthorityId": {NotEmpty()}}
)

请求参非空判断

View Source
var CustomizeMap = make(map[string]Rules)

Functions

func CreateDir

func CreateDir(dirs ...string) (err error)

CreateDir: 批量创建文件夹

func Eq

func Eq(mark string) string

Eq: 等于入参(==) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Ge

func Ge(mark string) string

Ge: 大于等于入参(>=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func GetWriteSyncer

func GetWriteSyncer() (zapcore.WriteSyncer, error)

GetWriteSyncer: zap logger中加入file-rotatelogs

func Gt

func Gt(mark string) string

Gt: 大于入参(>) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Le

func Le(mark string) string

Le: 小于等于入参(<=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Lt

func Lt(mark string) string

Lt: 小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func MD5V

func MD5V(str []byte) string

MD5加密

func Ne

func Ne(mark string) string

Ne: 不等于入参(!=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func NotEmpty

func NotEmpty() string

NotEmpty: 非空 不能为其对应类型的0值

func PathExists

func PathExists(path string) (bool, error)

PathExists: 文件目录是否存在

func RegisterRule

func RegisterRule(key string, rule Rules) (err error)

RegisterRule: 注册自定义规则方案建议在路由初始化层即注册

func Verify

func Verify(st interface{}, roleMap Rules) (err error)

Verify: 校验方法

Types

type Rules

type Rules map[string][]string

type RulesMap

type RulesMap map[string]Rules

Jump to

Keyboard shortcuts

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