CoreFilter

package
v5.1.38 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAddress

func CheckAddress(str string) bool

CheckAddress 检查详细收货地址

func CheckArray

func CheckArray(a, b []int64) bool

CheckArray 比较两组[]int64结构 检查每一项,左侧最大。反馈总数量最大的 用于版本号检查,最多支持4位 [1.0.0] -> [0.0.9] 左侧最大则反馈true,否则false 建议左侧为app实际安装,右侧为系统存储的版本,对比可得出最后是否需升级?

func CheckArrayEq

func CheckArrayEq(a, b []int64) bool

CheckArrayEq 检查两个数组是否相等

func CheckArrayStringHave

func CheckArrayStringHave(a, b []string) bool

CheckArrayStringHave 检查两个数据是否存在交集

func CheckArrayStringLeftMustHaveRight

func CheckArrayStringLeftMustHaveRight(a, b []string) bool

CheckArrayStringLeftMustHaveRight 检查右侧数据是否完整被左侧包含

func CheckCity

func CheckCity(str int) bool

CheckCity 检查地区英文标示 TODO:未来加入第三方库来计算,注意GPS记录的数据和用户地址数据可能有所区分,具体按照地图反馈数据来设计即可

func CheckCityCode

func CheckCityCode(str string) bool

CheckCityCode 检查地区编码

func CheckColor

func CheckColor(color string) bool

CheckColor 检查是否为颜色

func CheckContent

func CheckContent(str string, min int, max int) bool

CheckContent 检查消息内容

func CheckCountry

func CheckCountry(str int) bool

CheckCountry 检查国家英文标示

func CheckDes

func CheckDes(str string, min int, max int) bool

CheckDes 检查描述信息

func CheckEmail

func CheckEmail(str string) bool

CheckEmail 验证邮箱 param str string 邮箱地址 return bool 是否正确

func CheckExpireTime

func CheckExpireTime(expireTime string) bool

CheckExpireTime 检查过期时间

func CheckFileName

func CheckFileName(str string) bool

CheckFileName 检查文件名称

func CheckFilterStr

func CheckFilterStr(str string, min int, max int) string

CheckFilterStr 过滤非法字符后判断其长度是否符合标准 param str string 要过滤的字符串 param min int 最短,包括该长度 param max int 最长,包括该长度 return string 过滤后的字符串,失败返回空字符串

func CheckFromNameAndEmpty

func CheckFromNameAndEmpty(str string) bool

CheckFromNameAndEmpty 检查可以为空的字段名称信息

func CheckGPS

func CheckGPS(str float64) bool

CheckGPS 检查GPS坐标

func CheckHaveTime

func CheckHaveTime(d time.Time) bool

CheckHaveTime 判断是否具备时间 和sql模块内部旧的处理判断方法一致,用于检查是否具备时间,例如deleteAt是否已经删除等

func CheckHexSha1

func CheckHexSha1(str string) bool

CheckHexSha1 验证是否为SHA1 param str string 字符串 return bool 是否正确

func CheckHexSha256

func CheckHexSha256(str string) bool

CheckHexSha256 验证是否为SHA256 param str string 字符串 return bool 是否正确

func CheckHost

func CheckHost(str string) bool

CheckHost 验证host

func CheckID

func CheckID(str string) bool

CheckID 检查ID param str string ID序列 return bool 是否正确

func CheckIDCard

func CheckIDCard(str string) bool

CheckIDCard 验证身份证 因为复杂性,仅考虑验证身份证位数有效性 未来可根据实际需求加入外部API对身份证进行二次验证 param str string 身份证号码 return bool 是否正确

func CheckIP

func CheckIP(str string) bool

CheckIP 验证是否为IP地址 param str string IP地址 return bool 是否正确

func CheckInt64InArray

func CheckInt64InArray(arr []int64, c int64) bool

CheckInt64InArray 检查int64是否在列内

func CheckLimit

func CheckLimit(limit int, min int, max int) bool

CheckLimit 验证传统限制

func CheckMapType

func CheckMapType(str int) bool

CheckMapType 检查GPS标准

func CheckMark

func CheckMark(str string) bool

CheckMark 检查mark param str string return bool 是否正确

func CheckMarkPage

func CheckMarkPage(str string) bool

func CheckMax

func CheckMax(max int64) bool

CheckMax 检查页长

func CheckNationCode

func CheckNationCode(str string) bool

CheckNationCode 检查手机号国家代码 86

func CheckNiceName

func CheckNiceName(str string) bool

CheckNiceName 检查昵称 param str string 昵称 return bool 是否正确

func CheckPage

func CheckPage(page int64) bool

CheckPage 检查页数

func CheckPassword

func CheckPassword(str string) bool

CheckPassword 验证密码 param str string 密码 return bool 是否正确

func CheckPhone

func CheckPhone(str string) bool

CheckPhone 验证电话号码 必须是手机电话号码或带区号的固定电话号码 eg 03513168322 eg 13066889999

func CheckPort

func CheckPort(str string) bool

CheckPort 验证port

func CheckProvince

func CheckProvince(str int) bool

CheckProvince 检查省份

func CheckSN

func CheckSN(sn int64) bool

CheckSN 检查SN

func CheckSearch

func CheckSearch(str string) bool

CheckSearch 验证搜索类型的字符串 param str string 字符串 return bool 是否正确

func CheckSort

func CheckSort(sort string) bool

CheckSort 检查字段名称

func CheckTimeAfterNow

func CheckTimeAfterNow(d time.Time) bool

CheckTimeAfterNow 判断时间是否大于当前时间

func CheckTimeType

func CheckTimeType(str string) bool

CheckTimeType 检查时间类型

func CheckUsername

func CheckUsername(str string) bool

CheckUsername 检查用户名 param str string 用户名 return bool 是否正确

func CheckVcode

func CheckVcode(str string) bool

CheckVcode 检查验证码

func CutStringAndEncrypt

func CutStringAndEncrypt(str string, startN int, endN int) string

CutStringAndEncrypt 将文本进行加密处理 自动保留前N位和后N位 startN 开头保留前几位 endStartN 结尾保留后几位

func DerefInt64

func DerefInt64(s *int64) int64

DerefInt64 将引用int64改为非引用关系

func DerefString

func DerefString(s *string) string

DerefString 将引用字符串改为非引用关系

func EqHaveID2

func EqHaveID2(argID int64, arr []int64) (b bool)

EqHaveID2 是否包含ID

func EqID2

func EqID2(argID int64, dataID int64) (b bool)

EqID2 对比两个ID是否相同,第一个作为参数可以小于1

func FilterMax

func FilterMax(postMax string) int64

FilterMax 处理max 限制最小值为1,最大值为999 param postMax string 用户提交的max return int 过滤后的页数

func FilterMaxInt

func FilterMaxInt(postMax int64) int64

func FilterPage

func FilterPage(postPage string) int64

FilterPage 处理page param postPage string 用户提交的page return int 过滤后的页数

func FilterPageInt

func FilterPageInt(postPage int64) int64

func FilterStrForce

func FilterStrForce(str string) (newStr string)

FilterStrForce 强过滤字符串 param str string 要过滤的字符串 return string 过滤后的字符串

func GetAnalysisSQLTimeRange

func GetAnalysisSQLTimeRange(analysisType string, analysisAt string) (startAt carbon.Carbon, endAt carbon.Carbon)

GetAnalysisSQLTimeRange 获取统计的SQL时间范围 analysisType 统计周期类型 day 日统计;week 周统计;month 月统计; quarter 季度统计;year_h 半年统计;year 年统计; analysisAt 统计日期 eg: day: 2023-06-01 week: 2023-06-W1 / 2023-06-W2 / 2023-06-W3 / 2023-06-W4 month: 2023-06 quarter: 2023-Q1 / 2023-Q2 / 2023-Q3 / 2023-Q4 year_h: 2023-H1 / 2023-H2 year: 2023

func GetBoolByInterface

func GetBoolByInterface(data interface{}) (bool, error)

func GetBoolByInterfaceNoErr

func GetBoolByInterfaceNoErr(data interface{}) bool

func GetCarbonByTime

func GetCarbonByTime(t time.Time) carbon.Carbon

func GetFileIDListByContent

func GetFileIDListByContent(str string) ([]string, error)

GetFileIDListByContent 检索content文本内的所有file数据 识别方案:({\$file:)[a-zA-Z0-9]*(})

func GetFloat64ByInt

func GetFloat64ByInt(data int) float64

func GetFloat64ByInt64

func GetFloat64ByInt64(data int64) float64

func GetFloat64ByInterface

func GetFloat64ByInterface(data interface{}) (float64, error)

func GetFloat64ByString

func GetFloat64ByString(data string) (float64, error)

func GetFloat64ByStringNoErr

func GetFloat64ByStringNoErr(data string) float64

func GetFloat64ByUint8

func GetFloat64ByUint8(data []uint8) (float64, error)

func GetHalfYearByTimeCarbon

func GetHalfYearByTimeCarbon() string

GetHalfYearByTimeCarbon 获取当前时间是上半年还是下半年

func GetIDsInString

func GetIDsInString(str string, split string) []int64

func GetISOByTime

func GetISOByTime(timeAt time.Time) (newTime string)

GetISOByTime 将时间转为ISO格式输出

func GetInt64ByFloat64

func GetInt64ByFloat64(data float64) int64

func GetInt64ByInterface

func GetInt64ByInterface(data interface{}) (int64, error)

func GetInt64ByString

func GetInt64ByString(data string) (int64, error)

func GetInt64ByStringNoErr

func GetInt64ByStringNoErr(data string) int64

func GetInt64ByUint8

func GetInt64ByUint8(data []uint8) (int64, error)

func GetInt64ByUint8NoErr

func GetInt64ByUint8NoErr(data []uint8) int64

func GetIntByFloat64

func GetIntByFloat64(data float64) int

func GetIntByInterface

func GetIntByInterface(data interface{}) (int, error)

func GetIntByString

func GetIntByString(data string) (int, error)

func GetIntByStringNoErr

func GetIntByStringNoErr(data string) int

func GetMapKey

func GetMapKey(key int64, mapData map[int64]string) string

GetMapKey 从一组map中找到对应的键位,如果不存在则反馈空字符串

func GetMapKeys

func GetMapKeys(keys []int64, mapData map[int64]string) []string

func GetMaxRand

func GetMaxRand(maxCount int64, haveCount int64, sendCount int64, sendLimit int64) (result int64)

GetMaxRand 从一定额度下随机抽取 可用于红包的随机计算等 maxCount int64 允许给予的总额度 haveCount int64 已经发放的额度总额 sendCount int64 已经发放的数量 sendLimit int64 发出的数量限制

func GetMd5StrByStr

func GetMd5StrByStr(str string) string

GetMd5StrByStr 获取MD5字符串

func GetNowTime

func GetNowTime() time.Time

GetNowTime 获取当前时间

func GetNowTimeCarbon

func GetNowTimeCarbon() carbon.Carbon

func GetPriceByUint8

func GetPriceByUint8(data []uint8) int64

GetPriceByUint8 转化uint8为int64结构

func GetPriceToShowPrice

func GetPriceToShowPrice(data int64) float64

GetPriceToShowPrice 将金额转为float64并保留2位,显示使用的金额

func GetPriceToShowPriceStr added in v5.1.37

func GetPriceToShowPriceStr(data float64) string

GetPriceToShowPriceStr 将金额转为float64并保留2位,显示使用的金额

func GetQuarterByTimeCarbon

func GetQuarterByTimeCarbon() string

GetQuarterByTimeCarbon 获取当前时间的季度日期

func GetRandNumber

func GetRandNumber(min int, max int) int

GetRandNumber 生成指定范围的随机数字

func GetRandStr

func GetRandStr(n int) string

GetRandStr 获取随机字符串 param n int 随机码 return string 新随机字符串

func GetRandStr2

func GetRandStr2() string

GetRandStr2 获取随机字符串 第二代,自动生成混淆随机数,与时间混淆后计算得出

func GetRandStr3

func GetRandStr3(limit int) (string, error)

GetRandStr3 获取随机数 第三代,支持长度限制

func GetRandStr4

func GetRandStr4(limit int) string

GetRandStr4 获取随机数 隐藏错误信息

func GetRound

func GetRound(data float64) float64

GetRound 四舍五入取整数

func GetRoundToInt

func GetRoundToInt(data float64) int

func GetRoundToInt64

func GetRoundToInt64(data float64) int64

func GetSha1

func GetSha1(str []byte) ([]byte, error)

GetSha1 获取字符串SHA1摘要 该模块返回[]byte类型 param str []byte 要加密的字符串 return []byte SHA1值,加密失败则返回空字符串

func GetSha1ByString

func GetSha1ByString(content string) (string, error)

GetSha1ByString 获取字符串的SHA1值 param content string 要计算的字符串 return string 计算出的SHA1值 return error

func GetSha1Str

func GetSha1Str(str string) string

GetSha1Str 获取字符串SHA1摘要 该模块返回string类型 param str string 要加密的字符串 return string SHA1值,加密失败则返回空字符串

func GetSha1Str2

func GetSha1Str2(str string) (string, error)

GetSha1Str2 获取字符串SHA1摘要 该模块返回string类型 param str string 要加密的字符串 return string SHA1值,加密失败则返回空字符串

func GetSha256

func GetSha256(str []byte) ([]byte, error)

GetSha256 计算sha256 param str []byte 要加密的字符串 return []byte SHA256值,加密失败则返回空字符串

func GetSha256Str

func GetSha256Str(str string) (string, error)

GetSha256Str 获取sha256字符串 param str string 要计算的字符串 return string 字符串 return error 错误信息

func GetStringByFloat64

func GetStringByFloat64(data float64) string

func GetStringByInt

func GetStringByInt(data int) string

func GetStringByInt64

func GetStringByInt64(data int64) string

func GetStringByInterface

func GetStringByInterface(data interface{}) (string, error)

func GetStringByUint

func GetStringByUint(data uint) string

func GetStringByUint64

func GetStringByUint64(data uint64) string

func GetStructToMap

func GetStructToMap(structData interface{}, mapData *map[string]interface{}) error

GetStructToMap 将struct数组解析为map结构

func GetTimeBetweenAdd

func GetTimeBetweenAdd(addStr string) (int64, error)

GetTimeBetweenAdd 获取某个ADD时间点距离现在的秒数 注意,如果向前偏移,则可能出现负数!

func GetTimeBy30DayList

func GetTimeBy30DayList() []string

GetTimeBy30DayList 获取最近30天的列表

func GetTimeByAdd

func GetTimeByAdd(addStr string) (time.Time, error)

GetTimeByAdd 根据推移变量,获取实际的时间结构 直接放对应的时间+单位即可实现 such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

func GetTimeByDefault

func GetTimeByDefault(str string) (timeAt time.Time, err error)

GetTimeByDefault 将普通时间格式转为时间结构

func GetTimeByDefaultNoErr

func GetTimeByDefaultNoErr(str string) (timeAt time.Time)

GetTimeByDefaultNoErr 将普通时间格式转为时间结构(不反馈错误)

func GetTimeByDefaultTime

func GetTimeByDefaultTime(a, b string) (time.Time, time.Time, error)

GetTimeByDefaultTime 获取两个标准时间的时间

func GetTimeByISO

func GetTimeByISO(newTime string) (timeAt time.Time, err error)

GetTimeByISO 将ISO时间转为time

func GetTimeByTimeN

func GetTimeByTimeN(addTime carbon.Carbon, timeType int, timeN int) time.Time

GetTimeByTimeN 根据时间类型和时间长度,计算指定未来的时间 timeType: 0 小时 1 天 2 周 3 月 4 年

func GetTimeByUnix

func GetTimeByUnix(sec int64, nsec int64) time.Time

GetTimeByUnix 获取unix时间戳的时间结构体

func GetTimeCarbonByDefault

func GetTimeCarbonByDefault(str string) (timeAt carbon.Carbon, err error)

GetTimeCarbonByDefault 获取carbon时间

func GetTimeToDefaultDate

func GetTimeToDefaultDate(timeAt time.Time) (str string)

GetTimeToDefaultDate 将时间格式输出为日期结构

func GetTimeToDefaultTime

func GetTimeToDefaultTime(timeAt time.Time) (str string)

GetTimeToDefaultTime 将时间格式输出为标准时间结构

func GetUIntByInt

func GetUIntByInt(data int) uint

func GetUIntByString

func GetUIntByString(data string) (uint, error)

func GetURLNameType

func GetURLNameType(sendURL string) map[string]string

GetURLNameType 分解URL获取名称和类型 param sendURL URL地址 return map[string]string 返回值集合

func GetUnixStartTime

func GetUnixStartTime() time.Time

GetUnixStartTime 获取unix时间戳起点

func GetWeekOfMonthByTimeCarbon

func GetWeekOfMonthByTimeCarbon() string

GetWeekOfMonthByTimeCarbon 获取当前时间是本月第几周

func LoadTimeLocation

func LoadTimeLocation(location string) *time.Location

LoadTimeLocation 加载时区文件

func LoadTimeLocationChild

func LoadTimeLocationChild(location string) *time.Location

func MargeArrayString

func MargeArrayString(a, b []string) []string

MargeArrayString 合并两个数组并排重

func MargeNoReplaceArrayInt64

func MargeNoReplaceArrayInt64(a []int64, b int64) []int64

MargeNoReplaceArrayInt64 去重后写入数组

func MatchStr

func MatchStr(mStr string, str string) bool

MatchStr param mStr string 验证 param str string 要验证的字符串 return bool 是否成功

func MathLastProportion

func MathLastProportion(prev int64, last int64) (addCount int64, p float64)

MathLastProportion 计算提升后占比

func MathLastProportionToInt64

func MathLastProportionToInt64(prev int64, last int64) (addCount int64, p int64)

func RandomWeightedValue

func RandomWeightedValue(weights []int) (resultKey int)

RandomWeightedValue 通过一组int数组作为权重,随机并生成符合条件的权重值key

func RoundToTwoDecimalPlaces

func RoundToTwoDecimalPlaces(num float64) float64

RoundToTwoDecimalPlaces 四舍五入保留2位小数点

func SubStr

func SubStr(str string, start int, length int) string

SubStr 截取字符串 param str string 要截取的字符串 param star int 开始位置 param length int 长度 return string 新字符串

func SubStrQuick

func SubStrQuick(str string, limit int) string

SubStrQuick 快速截取字符串并输出...

Types

This section is empty.

Jump to

Keyboard shortcuts

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