Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(data []byte, key []byte) ([]byte, error)
- func AesEncrypt(data []byte, key []byte) ([]byte, error)
- func CopyFile(srcFile, dstFile string, delSource bool) (err error)
- func CryptoByMd5(data []byte, saltVal []byte) []byte
- func DecryptByAes(data, pwdKey string) (string, error)
- func EncryptByAes(data, pwdKey string) (string, error)
- func ExistIntArray(val int, array []int) bool
- func ExtractSummary(content string) string
- func ExtractTelephone(val string) (ret string)
- func GenerateKey(pwdKey []byte) []byte
- func GetAbove(val string) interface{}
- func GetBelow(val string) interface{}
- func GetEqual(val string) interface{}
- func GetIn(val string) interface{}
- func GetLike(val string) interface{}
- func GetNotEqual(val string) interface{}
- func GetNotIn(val string) interface{}
- func GetStack(skip int) []byte
- func IntArray2Str(ids []int) string
- func LoadConfig(filePath string, ptr interface{}) (err error)
- func MarshalString(val interface{}) string
- func NewUUID() string
- func RandomAlphaOrNumeric(count uint, letters, numbers bool) string
- func RandomAlphabetic(count uint) string
- func RandomAlphanumeric(count uint) string
- func RandomAscII(count uint) string
- func RandomIdentifyCode() string
- func RandomNumeric(count uint) string
- func RandomSpec0(count uint, start, end int, letters, numbers bool, chars []rune, ...) string
- func RandomSpec1(count uint, start, end int, letters, numbers bool) string
- func RandomString(count uint) string
- func RandomStringSpec0(count uint, set []rune) string
- func RandomStringSpec1(count uint, set string) string
- func SameIntArray(val []int, array []int) bool
- func SaveConfig(filePath string, ptr interface{}) (err error)
- func Str2IntArray(str string) ([]int, bool)
- func UnmarshalString(val string) interface{}
- func ValidateFunc(fun interface{})
- func ValidatePtr(ptr interface{})
- type CatalogObjectRegistry
- type ContentFilter
- func (s *ContentFilter) Above(key string, value interface{})
- func (s *ContentFilter) Below(key string, value interface{})
- func (s *ContentFilter) BindEntity(name, pkgPath string)
- func (s *ContentFilter) Decode(request *http.Request)
- func (s *ContentFilter) Encode(vals url.Values) url.Values
- func (s *ContentFilter) Equal(key string, value interface{})
- func (s *ContentFilter) Get(key string) (val string, ok bool)
- func (s *ContentFilter) GetAbove(key string) interface{}
- func (s *ContentFilter) GetBelow(key string) interface{}
- func (s *ContentFilter) GetEqual(key string) interface{}
- func (s *ContentFilter) GetIn(key string) interface{}
- func (s *ContentFilter) GetLike(key string) interface{}
- func (s *ContentFilter) GetName() string
- func (s *ContentFilter) GetNotEqual(key string) interface{}
- func (s *ContentFilter) GetNotIn(key string) interface{}
- func (s *ContentFilter) GetPkgKey() string
- func (s *ContentFilter) GetPkgPath() string
- func (s *ContentFilter) In(key string, value interface{})
- func (s *ContentFilter) Like(key string, value interface{})
- func (s *ContentFilter) NotEqual(key string, value interface{})
- func (s *ContentFilter) NotIn(key string, value interface{})
- func (s *ContentFilter) Pagination(ptr *Pagination)
- func (s *ContentFilter) Remove(key string)
- func (s *ContentFilter) Set(key string, value interface{})
- func (s *ContentFilter) SortFilter(ptr *SortFilter)
- func (s *ContentFilter) ValueMask(val any)
- type Filter
- type ID
- func ParseBase2(id string) (ID, error)
- func ParseBase32(b []byte) (ID, error)
- func ParseBase36(id string) (ID, error)
- func ParseBase58(b []byte) (ID, error)
- func ParseBase64(id string) (ID, error)
- func ParseBytes(id []byte) (ID, error)
- func ParseInt64(id int64) ID
- func ParseIntBytes(id [8]byte) ID
- func ParseString(id string) (ID, error)
- func (f ID) Base2() string
- func (f ID) Base32() string
- func (f ID) Base36() string
- func (f ID) Base58() string
- func (f ID) Base64() string
- func (f ID) Bytes() []byte
- func (f ID) Int64() int64
- func (f ID) IntBytes() [8]byte
- func (f ID) MarshalJSON() ([]byte, error)
- func (f ID) Node() int64
- func (f ID) Step() int64
- func (f ID) String() string
- func (f ID) Time() int64
- func (f *ID) UnmarshalJSON(b []byte) error
- type JSONSyntaxError
- type ObjectList
- type ObjectRegistry
- type ObjectSorter
- type Pagination
- type ParamItems
- func (s *ParamItems) Above(key string, value interface{})
- func (s *ParamItems) Below(key string, value interface{})
- func (s *ParamItems) Decode(request *http.Request) bool
- func (s *ParamItems) Encode(vals url.Values) url.Values
- func (s *ParamItems) Equal(key string, value interface{})
- func (s *ParamItems) GetAbove(key string) interface{}
- func (s *ParamItems) GetBelow(key string) interface{}
- func (s *ParamItems) GetEqual(key string) interface{}
- func (s *ParamItems) GetIn(key string) interface{}
- func (s *ParamItems) GetLike(key string) interface{}
- func (s *ParamItems) GetNotEqual(key string) interface{}
- func (s *ParamItems) GetNotIn(key string) interface{}
- func (s *ParamItems) In(key string, value interface{})
- func (s *ParamItems) IsAbove(key string) bool
- func (s *ParamItems) IsBelow(key string) bool
- func (s *ParamItems) IsEqual(key string) bool
- func (s *ParamItems) IsIn(key string) bool
- func (s *ParamItems) IsLike(key string) bool
- func (s *ParamItems) IsNotEqual(key string) bool
- func (s *ParamItems) IsNotIn(key string) bool
- func (s *ParamItems) Like(key string, value interface{})
- func (s *ParamItems) NotEqual(key string, value interface{})
- func (s *ParamItems) NotIn(key string, value interface{})
- type SnowFlakeNode
- type SortFilter
- type SortHelper
- type StringSet
- type Validator
Constants ¶
const CSTLayout = "2006-01-02 15:04:05"
const CSTLayoutWithMillisecond = "2006-01-02 15:04:05.0000"
Variables ¶
var ( // Epoch is set to Oct 10 2010 10:10:10 UTC in milliseconds // You may customize this to set a different epoch for your application. Epoch int64 = 1286676610000 // NodeBits holds the number of bits to use for SnowFlakeNode // Remember, you have a total 22 bits to share between SnowFlakeNode/Step NodeBits uint8 = 10 // StepBits holds the number of bits to use for Step // Remember, you have a total 22 bits to share between SnowFlakeNode/Step StepBits uint8 = 12 )
var ErrInvalidBase32 = errors.New("invalid base32")
ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte
var ErrInvalidBase58 = errors.New("invalid base58")
ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte
Functions ¶
func CryptoByMd5 ¶
func DecryptByAes ¶
DecryptByAes Decrypt using AES
func EncryptByAes ¶
EncryptByAes Encrypt using AES and then base64 encode
func ExtractTelephone ¶
func GenerateKey ¶ added in v1.3.109
GenerateKey Generates a secure key using SHA-256
func GetNotEqual ¶ added in v1.2.6
func GetNotEqual(val string) interface{}
func LoadConfig ¶
func MarshalString ¶
func MarshalString(val interface{}) string
func RandomAlphaOrNumeric ¶
RandomAlphaOrNumeric Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.
Param count - the length of random string to create Param letters - if true, generated string will include
alphabetic characters
Param numbers - if true, generated string will include
numeric characters
func RandomAlphabetic ¶
RandomAlphabetic Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alphabetic characters.
func RandomAlphanumeric ¶
RandomAlphanumeric Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters.
func RandomAscII ¶
RandomAscII Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters whose ASCII value is between 32 and 126 (inclusive).
func RandomNumeric ¶
RandomNumeric Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of numeric characters.
func RandomSpec0 ¶
func RandomSpec0(count uint, start, end int, letters, numbers bool, chars []rune, rand *rand.Rand) string
RandomSpec0 Creates a random string based on a variety of options, using supplied source of randomness.
If start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, unless letters and numbers are both false, in which case, start and end are set to 0 and math.MaxInt32.
If set is not nil, characters between start and end are chosen.
This method accepts a user-supplied rand.Rand instance to use as a source of randomness. By seeding a single rand.Rand instance with a fixed seed and using it for each call, the same random sequence of strings can be generated repeatedly and predictably.
func RandomSpec1 ¶
RandomSpec1 Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.
Param count - the length of random string to create Param start - the position in set of chars to start at Param end - the position in set of chars to end before Param letters - if true, generated string will include
alphabetic characters
Param numbers - if true, generated string will include
numeric characters
func RandomStringSpec0 ¶
RandomStringSpec0 RandomStringSpec0
func RandomStringSpec1 ¶
RandomStringSpec1 RandomStringSpec1
func SaveConfig ¶
func UnmarshalString ¶
func UnmarshalString(val string) interface{}
Types ¶
type CatalogObjectRegistry ¶
type CatalogObjectRegistry interface { Put(id, catalog string, object interface{}) Get(id, catalog string) interface{} Sort(catalog string, sorter ObjectSorter) FetchList(catalog string, pageFilter *Pagination) *ObjectList Filter(catalog string, filter Filter, pageFilter *Pagination) *ObjectList Remove(id, catalog string) }
CatalogObjectRegistry catalog object registry
func NewCatalogRegistry ¶
func NewCatalogRegistry() CatalogObjectRegistry
NewCatalogRegistry create new catalog registry
type ContentFilter ¶
type ContentFilter struct { PaginationPtr *Pagination `json:"pagination"` ParamItems *ParamItems `json:"params"` }
ContentFilter 过滤器
func (*ContentFilter) Above ¶
func (s *ContentFilter) Above(key string, value interface{})
func (*ContentFilter) Below ¶
func (s *ContentFilter) Below(key string, value interface{})
func (*ContentFilter) BindEntity ¶ added in v1.3.14
func (s *ContentFilter) BindEntity(name, pkgPath string)
func (*ContentFilter) Encode ¶
func (s *ContentFilter) Encode(vals url.Values) url.Values
Encode encode filter
func (*ContentFilter) Equal ¶
func (s *ContentFilter) Equal(key string, value interface{})
func (*ContentFilter) GetAbove ¶ added in v1.3.18
func (s *ContentFilter) GetAbove(key string) interface{}
func (*ContentFilter) GetBelow ¶ added in v1.3.18
func (s *ContentFilter) GetBelow(key string) interface{}
func (*ContentFilter) GetEqual ¶ added in v1.3.18
func (s *ContentFilter) GetEqual(key string) interface{}
func (*ContentFilter) GetIn ¶ added in v1.3.18
func (s *ContentFilter) GetIn(key string) interface{}
func (*ContentFilter) GetLike ¶ added in v1.3.18
func (s *ContentFilter) GetLike(key string) interface{}
func (*ContentFilter) GetName ¶ added in v1.3.1
func (s *ContentFilter) GetName() string
func (*ContentFilter) GetNotEqual ¶ added in v1.3.18
func (s *ContentFilter) GetNotEqual(key string) interface{}
func (*ContentFilter) GetNotIn ¶ added in v1.3.18
func (s *ContentFilter) GetNotIn(key string) interface{}
func (*ContentFilter) GetPkgKey ¶ added in v1.3.62
func (s *ContentFilter) GetPkgKey() string
func (*ContentFilter) GetPkgPath ¶ added in v1.3.1
func (s *ContentFilter) GetPkgPath() string
func (*ContentFilter) In ¶
func (s *ContentFilter) In(key string, value interface{})
func (*ContentFilter) Like ¶
func (s *ContentFilter) Like(key string, value interface{})
func (*ContentFilter) NotEqual ¶
func (s *ContentFilter) NotEqual(key string, value interface{})
func (*ContentFilter) NotIn ¶
func (s *ContentFilter) NotIn(key string, value interface{})
func (*ContentFilter) Pagination ¶
func (s *ContentFilter) Pagination(ptr *Pagination)
func (*ContentFilter) Remove ¶
func (s *ContentFilter) Remove(key string)
func (*ContentFilter) Set ¶
func (s *ContentFilter) Set(key string, value interface{})
func (*ContentFilter) SortFilter ¶ added in v1.3.10
func (s *ContentFilter) SortFilter(ptr *SortFilter)
func (*ContentFilter) ValueMask ¶ added in v1.3.10
func (s *ContentFilter) ValueMask(val any)
type ID ¶ added in v1.3.4
type ID int64
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
func ParseBase2 ¶ added in v1.3.4
ParseBase2 converts a Base2 string into a snowflake ID
func ParseBase32 ¶ added in v1.3.4
ParseBase32 parses a base32 []byte into a snowflake ID NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func ParseBase36 ¶ added in v1.3.4
ParseBase36 converts a Base36 string into a snowflake ID
func ParseBase58 ¶ added in v1.3.4
ParseBase58 parses a base58 []byte into a snowflake ID
func ParseBase64 ¶ added in v1.3.4
ParseBase64 converts a base64 string into a snowflake ID
func ParseBytes ¶ added in v1.3.4
ParseBytes converts a byte slice into a snowflake ID
func ParseInt64 ¶ added in v1.3.4
ParseInt64 converts an int64 into a snowflake ID
func ParseIntBytes ¶ added in v1.3.4
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake ID
func ParseString ¶ added in v1.3.4
ParseString converts a string into a snowflake ID
func (ID) Base32 ¶ added in v1.3.4
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func (ID) IntBytes ¶ added in v1.3.4
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (ID) MarshalJSON ¶ added in v1.3.4
MarshalJSON returns a json byte array string of the snowflake ID.
func (ID) Node ¶ added in v1.3.4
SnowFlakeNode returns an int64 of the snowflake ID node number DEPRECATED: the below function will be removed in a future release.
func (ID) Step ¶ added in v1.3.4
Step returns an int64 of the snowflake step (or sequence) number DEPRECATED: the below function will be removed in a future release.
func (ID) Time ¶ added in v1.3.4
Time returns an int64 unix timestamp in milliseconds of the snowflake ID time DEPRECATED: the below function will be removed in a future release.
func (*ID) UnmarshalJSON ¶ added in v1.3.4
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type JSONSyntaxError ¶ added in v1.3.4
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.
func (JSONSyntaxError) Error ¶ added in v1.3.4
func (j JSONSyntaxError) Error() string
type ObjectRegistry ¶
type ObjectRegistry interface { Put(id string, object interface{}) Get(id string) interface{} Sort(sorter ObjectSorter) FetchList(pageFilter *Pagination) *ObjectList Filter(filter Filter, pageFilter *Pagination) *ObjectList Remove(id string) }
ObjectRegistry object 仓库
type ObjectSorter ¶
type ObjectSorter interface {
Less(left, right interface{}) bool
}
ObjectSorter help object slice sort
type Pagination ¶
type Pagination struct { // 单页条目数 PageSize int `json:"pageSize"` // 页码 PageNum int `json:"pageNum"` }
Pagination 页面过滤器
func DefaultPagination ¶
func DefaultPagination() *Pagination
func NewPagination ¶
func NewPagination(defaultSize, defaultNum int) *Pagination
type ParamItems ¶
type ParamItems struct { Name string `json:"name"` PkgPath string `json:"pkgPath"` Items map[string]string `json:"items"` SortFilter *SortFilter `json:"sortFilter"` ValueMask json.RawMessage `json:"valueMask"` }
ParamItems contentFilter
func (*ParamItems) Above ¶ added in v1.3.22
func (s *ParamItems) Above(key string, value interface{})
func (*ParamItems) Below ¶ added in v1.3.22
func (s *ParamItems) Below(key string, value interface{})
func (*ParamItems) Encode ¶
func (s *ParamItems) Encode(vals url.Values) url.Values
Encode ParamItems
func (*ParamItems) Equal ¶ added in v1.3.22
func (s *ParamItems) Equal(key string, value interface{})
func (*ParamItems) GetAbove ¶
func (s *ParamItems) GetAbove(key string) interface{}
func (*ParamItems) GetBelow ¶
func (s *ParamItems) GetBelow(key string) interface{}
func (*ParamItems) GetEqual ¶
func (s *ParamItems) GetEqual(key string) interface{}
func (*ParamItems) GetIn ¶
func (s *ParamItems) GetIn(key string) interface{}
func (*ParamItems) GetLike ¶
func (s *ParamItems) GetLike(key string) interface{}
func (*ParamItems) GetNotEqual ¶
func (s *ParamItems) GetNotEqual(key string) interface{}
func (*ParamItems) GetNotIn ¶
func (s *ParamItems) GetNotIn(key string) interface{}
func (*ParamItems) In ¶ added in v1.3.22
func (s *ParamItems) In(key string, value interface{})
func (*ParamItems) IsAbove ¶
func (s *ParamItems) IsAbove(key string) bool
func (*ParamItems) IsBelow ¶
func (s *ParamItems) IsBelow(key string) bool
func (*ParamItems) IsEqual ¶
func (s *ParamItems) IsEqual(key string) bool
func (*ParamItems) IsIn ¶
func (s *ParamItems) IsIn(key string) bool
func (*ParamItems) IsLike ¶
func (s *ParamItems) IsLike(key string) bool
func (*ParamItems) IsNotEqual ¶
func (s *ParamItems) IsNotEqual(key string) bool
func (*ParamItems) IsNotIn ¶
func (s *ParamItems) IsNotIn(key string) bool
func (*ParamItems) Like ¶ added in v1.3.22
func (s *ParamItems) Like(key string, value interface{})
func (*ParamItems) NotEqual ¶ added in v1.3.22
func (s *ParamItems) NotEqual(key string, value interface{})
func (*ParamItems) NotIn ¶ added in v1.3.22
func (s *ParamItems) NotIn(key string, value interface{})
type SnowFlakeNode ¶ added in v1.3.4
type SnowFlakeNode struct {
// contains filtered or unexported fields
}
A SnowFlakeNode struct holds the basic information needed for a snowflake generator node
func NewSnowFlakeNode ¶ added in v1.3.4
func NewSnowFlakeNode(node int64) (*SnowFlakeNode, error)
NewSnowFlakeNode returns a new snowflake node that can be used to generate snowflake IDs
func (*SnowFlakeNode) Generate ¶ added in v1.3.4
func (n *SnowFlakeNode) Generate() ID
Generate creates and returns a unique snowflake ID To help guarantee uniqueness - Make sure your system is keeping accurate system time - Make sure you never have multiple nodes running with the same node ID
type SortFilter ¶
type SortFilter struct { // true:升序,false:降序 AscFlag bool `json:"ascFlag"` // 排序字段 FieldName string `json:"fieldName"` }
SortFilter 页面过滤器
func NewSortFilter ¶
func NewSortFilter(name string, ascFlag bool) *SortFilter
func (*SortFilter) AscSort ¶
func (s *SortFilter) AscSort() bool
type SortHelper ¶
type SortHelper struct {
// contains filtered or unexported fields
}
SortHelper sortHelper
func NewSortHelper ¶
func NewSortHelper(objList []interface{}, sorter ObjectSorter) *SortHelper
NewSortHelper new SortHelper
func (SortHelper) Len ¶
func (s SortHelper) Len() int
func (SortHelper) Less ¶
func (s SortHelper) Less(i, j int) bool
func (SortHelper) Swap ¶
func (s SortHelper) Swap(i, j int)