Documentation
¶
Index ¶
- Variables
- func ContainsChinese(text string) bool
- func HidePhoneMiddle(phone string) string
- func InSlice(str string, s []string) bool
- func IsChinesePhone(phone string) bool
- func IsLetterOrDigit(s string) bool
- func IsPhone(phone string) bool
- func IsValidObjectID(s string) bool
- func Md5String(s string, multi ...string) string
- func PasswordSlatMD5(password, slat string) string
- func RandAlphaNumString(strLen int, lower ...bool) string
- func RandNumCode(strLen int) string
- func SetReqDataContext(ctx context.Context, data ReqData) context.Context
- func SliceRemoveDuplicate(x interface{}, fn func(i, j int) bool)
- func StrRangeN(str string, n int) string
- func Substr(str string, start, length int) string
- func Substring(str string, start, end int) string
- func TrimStringToFloat(s string) (float64, error)
- func TrimStringToInt(s string) (int, error)
- func UniqueSlice(s []string, isDropEmpty bool) []string
- type BaseResp
- type DataResp
- type IdOmitReq
- type IdReq
- type IntSplit
- type IsLimit
- type ListResp
- type LoginReq
- type LoginResp
- type ObjectID
- type PageReq
- type ReqData
- type StringSplit
- type TimeStringReq
- type TimestampReq
- type UidOmitReq
- type UidReq
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHex = errors.New("the provided hex string is not a valid ObjectID")
ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.
Functions ¶
func ContainsChinese ¶ added in v0.3.9
ContainsChinese 是否存在中文字符
func HidePhoneMiddle ¶ added in v0.1.0
HidePhoneMiddle eg:86-187****0987
func IsValidObjectID ¶ added in v0.3.9
IsValidObjectID returns true if the provided hex string represents a valid ObjectID and false if not.
func PasswordSlatMD5 ¶ added in v0.3.9
PasswordSlatMD5 md5 pwd & slat
func RandAlphaNumString ¶ added in v0.3.9
RandAlphaNumString rand x len string
func RandNumCode ¶ added in v0.3.9
RandNumCode rand number verify code, max len 20
func SetReqDataContext ¶ added in v0.3.3
func SliceRemoveDuplicate ¶ added in v0.3.5
SliceRemoveDuplicate 切片去重
func Substr ¶ added in v0.3.9
Substr if start < 0, desc, if arg invalid, return str [start,start+length)
func Substring ¶ added in v0.3.9
Substring if start < 0, desc, if arg invalid, return str [start,end)
func TrimStringToFloat ¶ added in v0.3.7
func TrimStringToInt ¶ added in v0.3.7
func UniqueSlice ¶ added in v0.3.9
UniqueSlice 切片去重,是否去掉空字符串,切片顺序不变
Types ¶
type BaseResp ¶ added in v0.3.3
func NewBaseResp ¶ added in v0.3.3
type DataResp ¶ added in v0.3.3
type DataResp struct { *BaseResp Data interface{} `json:"data"` }
func NewDataResp ¶ added in v0.3.3
type ObjectID ¶ added in v0.3.9
type ObjectID [12]byte
ObjectID is the BSON ObjectID type.
var NilObjectID ObjectID
NilObjectID is the zero value for ObjectID.
func NewObjectID ¶ added in v0.3.9
func NewObjectID() ObjectID
NewObjectID generates a new ObjectID.
func NewObjectIDFromTimestamp ¶ added in v0.3.9
NewObjectIDFromTimestamp generates a new ObjectID based on the given time.
func ObjectIDFromHex ¶ added in v0.3.9
ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.
func (ObjectID) MarshalJSON ¶ added in v0.3.9
MarshalJSON returns the ObjectID as a string
func (*ObjectID) UnmarshalJSON ¶ added in v0.3.9
UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 24 bytes long, it will be populated with the hex representation of the ObjectID. If the byte slice is twelve bytes long, it will be populated with the BSON representation of the ObjectID. This method also accepts empty strings and decodes them as NilObjectID. For any other inputs, an error will be returned.
type PageReq ¶
type PageReq struct { Page int `json:"page" form:"page,default=1" binding:"required,gte=1"` Size int `json:"size" form:"size,default=20" binding:"required,gte=1,lte=1000"` }
func (PageReq) LimitStart ¶ added in v0.0.4
type ReqData ¶ added in v0.3.3
type ReqData struct { Route string RemoteAddr string Uid string Body string Msg string // 补充信息 InternalErr string // contains filtered or unexported fields }
func GetReqDataContext ¶ added in v0.3.3
type StringSplit ¶ added in v0.3.7
type StringSplit string
func (StringSplit) Marshal ¶ added in v0.3.7
func (ss StringSplit) Marshal(val []string, sep string) StringSplit
func (StringSplit) Unmarshal ¶ added in v0.3.7
func (ss StringSplit) Unmarshal(sep string) []string
type TimeStringReq ¶
type TimeStringReq struct { // format 2006-01-02 15:04:05 StartTime string `json:"startTime" form:"startTime"` EndTime string `json:"endTime" form:"endTime"` }
func (TimeStringReq) FieldMgoBson ¶ added in v0.0.4
func (req TimeStringReq) FieldMgoBson() (map[string]interface{}, bool)
func (TimeStringReq) FieldSQLCond ¶
func (req TimeStringReq) FieldSQLCond(field string) []string
type TimestampReq ¶
type TimestampReq struct { // Unix timestamp Sec StartTimestamp int64 `json:"startTimestamp" form:"startTimestamp,default=0" binding:"omitempty,min=0"` EndTimestamp int64 `json:"endTimestamp" form:"endTimestamp,default=0" binding:"omitempty,gtefield=StartTimestamp"` }
func (TimestampReq) FieldMgoBson ¶ added in v0.0.4
func (req TimestampReq) FieldMgoBson() (map[string]interface{}, bool)
func (TimestampReq) FieldSQLCond ¶
func (req TimestampReq) FieldSQLCond(field string) []string
type UidOmitReq ¶
type UidOmitReq struct {
Uid int64 `json:"uid" form:"uid" binding:"omitempty,min=1"`
}