data

package
v0.0.0-...-0090c64 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	U62UtilLock   sync.Mutex     //保存锁
	U62UtilNumber            = 0 //序号

	U62UtilArray map[int]string = map[int]string{
		0:  "0",
		1:  "1",
		2:  "2",
		3:  "3",
		4:  "4",
		5:  "5",
		6:  "6",
		7:  "7",
		8:  "8",
		9:  "9",
		10: "a",
		11: "b",
		12: "c",
		13: "d",
		14: "e",
		15: "f",
		16: "g",
		17: "h",
		18: "i",
		19: "j",
		20: "k",
		21: "l",
		22: "m",
		23: "n",
		24: "o",
		25: "p",
		26: "q",
		27: "r",
		28: "s",
		29: "t",
		30: "u",
		31: "v",
		32: "w",
		33: "x",
		34: "y",
		35: "z",
		36: "A",
		37: "B",
		38: "C",
		39: "D",
		40: "E",
		41: "F",
		42: "G",
		43: "H",
		44: "I",
		45: "J",
		46: "K",
		47: "L",
		48: "M",
		49: "N",
		50: "O",
		51: "P",
		52: "Q",
		53: "R",
		54: "S",
		55: "T",
		56: "U",
		57: "V",
		58: "W",
		59: "X",
		60: "Y",
		61: "Z"}
)
View Source
var (
	CacheTxtUtilLock sync.Mutex //同步锁
)
View Source
var (
	SequenceUtilLock sync.Mutex //同步锁

)

Functions

This section is empty.

Types

type AesUtil

type AesUtil struct{}

func (AesUtil) AesDecrypt

func (this AesUtil) AesDecrypt(data []byte, key string) ([]byte, error)

AesDecrypt 解密

func (AesUtil) AesEncrypt

func (this AesUtil) AesEncrypt(data []byte, key string) ([]byte, error)

AesEncrypt 加密

func (AesUtil) Decrypt

func (this AesUtil) Decrypt(data string, key string) string

DecryptByAes Aes 解密16进制

func (AesUtil) DecryptBase64

func (this AesUtil) DecryptBase64(data string, key string) string

DecryptByAes Aes 解密

func (AesUtil) Encrypt

func (this AesUtil) Encrypt(data string, key string) string

EncryptByAes Aes加密 后 返回16进制

func (AesUtil) EncryptBase64

func (this AesUtil) EncryptBase64(data string, key string) string

EncryptByAes Aes加密 后 base64 再加转字符串

type Base64Util

type Base64Util struct{}

func (Base64Util) Base64ToPng

func (Base64Util) Base64ToPng(base64Data, savePath string) *MsgEmity

Base64转换为PNG图片

type CachePool

type CachePool struct{}

自定义缓存池

func (CachePool) Add

func (this CachePool) Add(cacheInfo CacheInfo) *MsgEmity

* * 添加缓存 * @param cacheInfo * @return

func (CachePool) AddData

func (this CachePool) AddData(sId string, data interface{}) *MsgEmity

* * 添加缓存 * @param sId * @param oData * @return

func (CachePool) Clear

func (this CachePool) Clear() *MsgEmity

*

  • 清理缓存
  • @return

func (CachePool) Contains

func (this CachePool) Contains(sId string) bool

* * 判断是否包含缓存,包含返回true * @param sId * @return

func (CachePool) Find

func (this CachePool) Find(sId string) *CacheInfo

* * 查找缓存信息 * @param sId * @return

func (CachePool) FindData

func (this CachePool) FindData(sId string) interface{}

* * 查找缓存对象 * @param sId * @return

func (CachePool) Free

func (this CachePool) Free(sId string) *MsgEmity

* * 释放缓存 * @param sId * @return

func (CachePool) FreeByData

func (this CachePool) FreeByData(data interface{}) *MsgEmity

* * 释放缓存 * @param sId * @return

func (CachePool) FreeById

func (this CachePool) FreeById(sId string) *MsgEmity

* * 释放缓存 * @param sId * @return

func (CachePool) FreeByTime

func (this CachePool) FreeByTime(iMinute int) *MsgEmity

* * 释放指定分钟之前的缓存 * @param iMinute * @return

type CacheTxtUtil

type CacheTxtUtil struct{}

func (CacheTxtUtil) CreateCacheFile

func (this CacheTxtUtil) CreateCacheFile(object interface{}, sCacheFile string) *MsgEmity

*

  • 创建缓存文件
  • @param object 待存储数据对象
  • @param sCacheFile 缓存文件路径及文件名
  • @return

func (CacheTxtUtil) CreateCacheFileByList

func (this CacheTxtUtil) CreateCacheFileByList(list []interface{}, sCacheFile string) *MsgEmity

*

  • 创建缓存文件
  • @param list 数据集合
  • @param sCacheFile 缓存文件路径及文件名
  • @return

func (CacheTxtUtil) DelCacheFile

func (this CacheTxtUtil) DelCacheFile(sCacheFile string) *MsgEmity

*

  • 删除缓存文件
  • @param sCacheFile

func (CacheTxtUtil) ReadCacheFile

func (this CacheTxtUtil) ReadCacheFile(sCacheFile ...string) []interface{}

*

  • 读取缓存文件
  • @param sCacheFile 缓存文件路径及文件名
  • @return

type FloatUtil

type FloatUtil struct{}

func (FloatUtil) Byte2Str

func (this FloatUtil) Byte2Str(b []byte) string

Byte转Str

func (FloatUtil) ToFloat

func (this FloatUtil) ToFloat(obj interface{}, bitSize int, iDefault float64) float64

对象(字符串)转64整型

func (FloatUtil) ToStr

func (this FloatUtil) ToStr(obj float64) string

对象(字符串)转浮点数

type IntegerUtil

type IntegerUtil struct{}

func (IntegerUtil) Byte2Str

func (iu IntegerUtil) Byte2Str(b []byte) string

Byte转Str

func (IntegerUtil) MaxInt

func (iu IntegerUtil) MaxInt() int

取int最大值

func (IntegerUtil) MinInt

func (iu IntegerUtil) MinInt() int

取int最小值

func (IntegerUtil) ToInt

func (iu IntegerUtil) ToInt(obj interface{}, iDefault ...int) int

对象(字符串)转整型

func (IntegerUtil) ToInt64

func (iu IntegerUtil) ToInt64(obj interface{}, iDefault int64) int64

对象(字符串)转64整型

type IpUtil

type IpUtil struct{}

func (IpUtil) GetIP

func (this IpUtil) GetIP(ctx *gin.Context) string

获取访问IP

func (IpUtil) GetOutBoundIP

func (this IpUtil) GetOutBoundIP() (ip string, err error)

获取本机ip地址

type JsonUtil

type JsonUtil struct{}

func (JsonUtil) ArrayFromFile

func (this JsonUtil) ArrayFromFile(path string) ([]map[string]interface{}, error)

文件转JsonArray

func (JsonUtil) FormFile

func (this JsonUtil) FormFile(path string, entity interface{}) *model.MsgEmity

文件转换到结构

func (JsonUtil) JsonToMap

func (this JsonUtil) JsonToMap(jsonStr string) (map[string]string, error)

json字符串转map

func (JsonUtil) MapFromFile

func (this JsonUtil) MapFromFile(path string) (map[string]interface{}, error)

文件转map

func (JsonUtil) ToFile

func (this JsonUtil) ToFile(data interface{}, path string) bool

转换json到文件

func (JsonUtil) ToMap

func (this JsonUtil) ToMap(jsonStr string) (map[string]interface{}, error)

json字符串转map

func (JsonUtil) ToObj

func (this JsonUtil) ToObj(str string, entity interface{}) *model.MsgEmity

内容转换到结构实体

func (JsonUtil) ToStr

func (this JsonUtil) ToStr(data interface{}) string

*

  • 对象转换到字符串
  • 直接使用json.Marshal存在转义问题,例如'&变成\u0026'

type LocalTime

type LocalTime time.Time

自定义时间类型

func (*LocalTime) MarshalJSON

func (t *LocalTime) MarshalJSON() ([]byte, error)

重写MarshalJSON方法来实现gorm查询时间字段事数据解析

func (LocalTime) Now

func (t LocalTime) Now() *LocalTime

取当前时间

func (*LocalTime) Scan

func (t *LocalTime) Scan(v interface{}) error

在数据查询出来之前对数据进⾏相关操作

type MapUtil

type MapUtil struct{}

func (MapUtil) HasName

func (mu MapUtil) HasName(data map[string]interface{}, name string) bool

判断是否存在指定键

func (MapUtil) RemoveData

func (mu MapUtil) RemoveData(data map[string]interface{}, filter []string)

移除指定键

type Md5

type Md5 struct{}

func (Md5) Lower

func (md Md5) Lower(str ...interface{}) string

取MD5小写

func (Md5) Upper

func (md Md5) Upper(str ...interface{}) string

取MD5,大写

type RiotUtil

type RiotUtil struct{}

func (RiotUtil) Add

func (this RiotUtil) Add(dbName, key, data string) *MsgEmity

添加

func (RiotUtil) Adds

func (this RiotUtil) Adds(dbName string, data map[string]string) *MsgEmity

添加

func (RiotUtil) Del

func (this RiotUtil) Del(dbName, key string) *MsgEmity

删除

func (RiotUtil) Find

func (this RiotUtil) Find(dbName, key string, entity interface{}) *MsgEmity

搜索

type SequenceUtil

type SequenceUtil struct{}

func (SequenceUtil) Get

func (this SequenceUtil) Get() string

* * 取时间显示式的流水号 * @return 返回形式举例:20200521094216048001

func (SequenceUtil) GetSequence

func (this SequenceUtil) GetSequence(iMaxLength int, prefix ...string) string

* * 取指定长度的流水号 * @param iMaxLength 指定长度 * @param prefix 前缀 * @return

func (SequenceUtil) GetSeriesNum

func (this SequenceUtil) GetSeriesNum(prefix string) string

* * 取累计值(有代码锁) * @param prefix 前缀 * @return

type Sha256Util

type Sha256Util struct{}

func (Sha256Util) GenRsaKey

func (this Sha256Util) GenRsaKey() (string, string, error)

RSA公钥私钥产生

func (Sha256Util) RsaDecrypt

func (this Sha256Util) RsaDecrypt(ciphertext, keyBytes string) (string, error)

私钥解密

func (Sha256Util) RsaEncrypt

func (this Sha256Util) RsaEncrypt(data, keyBytes string) (string, error)

公钥加密

func (Sha256Util) RsaSignWithSha256

func (this Sha256Util) RsaSignWithSha256(data, keyBytes string) (string, error)

签名

func (Sha256Util) RsaVerySignWithSha256

func (this Sha256Util) RsaVerySignWithSha256(data, signData, keyBytes string) (bool, error)

验证

type StringUtil

type StringUtil struct{}

func (StringUtil) Append

func (su StringUtil) Append(data ...interface{}) string

字符串拼接

func (StringUtil) Byte2Str

func (su StringUtil) Byte2Str(b []byte) string

Byte转Str

func (StringUtil) ChangeBetween

func (su StringUtil) ChangeBetween(source, beginStr, endStr, newStr string, lastIndexOf bool) string

*

  • 替换指定字符串间的内容(仅一次),并返回新值
  • @param source 源
  • @param beginStr 开始字符串
  • @param endStr 结束字符串
  • @param newStr 新字符串
  • @param lastIndexOf 是否从后面开始去截取字符串
  • @return

func (StringUtil) DelStr

func (this StringUtil) DelStr(source string, sub ...string) string

*

  • 彻底替换指定内容
  • @param source 源字符串
  • @param sub 待删除子字符串
  • @return

func (StringUtil) FirstLower

func (su StringUtil) FirstLower(s string) string

FirstLower 字符串首字母小写

func (StringUtil) FirstUpper

func (su StringUtil) FirstUpper(s string) string

FirstUpper 字符串首字母大写

func (StringUtil) Has

func (su StringUtil) Has(source, str string) bool

判断是否包含子串

func (StringUtil) HasEnd

func (su StringUtil) HasEnd(str, end string) bool

判断是否以特定字符结尾

func (StringUtil) HasStart

func (su StringUtil) HasStart(str, start string) bool

判断是否以特定字符开头

func (StringUtil) HasStr

func (this StringUtil) HasStr(data interface{}, str string) bool

*

  • 判断是否存在字符串
  • @param str
  • @return

func (StringUtil) IsAllChineseChar

func (su StringUtil) IsAllChineseChar(str string) bool

*

  • 是否全中文,全中文返回true
  • @param str
  • @return

func (StringUtil) IsCompriseChineseChar

func (su StringUtil) IsCompriseChineseChar(str string) bool

*

  • 是否包含中文,含中文返回true
  • @param str
  • @return

func (StringUtil) IsLowerStart

func (su StringUtil) IsLowerStart(s string) bool

是否小写开头

func (StringUtil) IsUpperStart

func (su StringUtil) IsUpperStart(s string) bool

是否大写开头

func (StringUtil) Lower

func (su StringUtil) Lower(str string) string

将字符串小写

func (StringUtil) RemoveBetween

func (su StringUtil) RemoveBetween(source, beginStr, endStr string, lastIndexOf bool) string

*

  • 移除指定字符串间的内容(仅一次),并返回新值
  • @param source 源
  • @param beginStr 开始字符串
  • @param endStr 结束字符串
  • @param lastIndexOf 是否从后面开始去截取字符串
  • @return

func (StringUtil) ReplaceAll

func (this StringUtil) ReplaceAll(source, old, new string) string

*

  • 彻底替换指定内容
  • @param source
  • @param old
  • @param new
  • @return

func (StringUtil) SubBetween

func (su StringUtil) SubBetween(source, beginStr, endStr string, lastIndexOf bool) string

*

  • 截取指定字符串间的内容
  • @param source 源
  • @param beginStr 开始字符串
  • @param endStr 结束字符串
  • @param lastIndexOf 是否从后面开始去截取字符串
  • @return

func (StringUtil) SubMaxStr

func (su StringUtil) SubMaxStr(source string, beginIndex, endMaxIndex int) string

*

  • 截取字符串
  • @param source 源字符串
  • @param beginIndex 开始位置 0开始
  • @param endMaxIndex 最大结束位置,超出则取字符串最大位置
  • @return

func (StringUtil) SupplyZero

func (this StringUtil) SupplyZero(formatLong int, data interface{}) string

*

  • 彻底替换指定内容
  • @param formatLong
  • @param data
  • @return

func (StringUtil) ToStr

func (su StringUtil) ToStr(data interface{}) string

转换字符串

func (StringUtil) Trim

func (su StringUtil) Trim(str string) string

清除前后空格

func (StringUtil) TrimAttribute

func (su StringUtil) TrimAttribute(data map[string]interface{})

清理map中字符串类型数据的前后空格

func (StringUtil) Upper

func (su StringUtil) Upper(str string) string

将字符串大写

type TimeUtil

type TimeUtil struct{}

func (TimeUtil) Add

func (this TimeUtil) Add(date time.Time, iT ...int) time.Time

* * 获取指定分钟后的时间 * @param date 起始时间 * @param iT 时间参数,分别是年、月、日、时、分、秒 * @return

func (TimeUtil) AddDay

func (this TimeUtil) AddDay(date time.Time, iCount int) time.Time

* * 获取指定天数后的时间 * @param date 起始时间 * @param iCount 天数 * @return

func (TimeUtil) AddHour

func (this TimeUtil) AddHour(date time.Time, iCount int) time.Time

* * 获取指定小时后的时间 * @param date 起始时间 * @param iCount 小时数 * @return

func (TimeUtil) AddMinute

func (this TimeUtil) AddMinute(date time.Time, iCount int) time.Time

* * 获取指定分钟后的时间 * @param date 起始时间 * @param iCount 分数 * @return

func (TimeUtil) AddMonth

func (this TimeUtil) AddMonth(date time.Time, iCount int) time.Time

* * 获取指定月后的时间 * @param date 起始时间 * @param iCount 月数 * @return

func (TimeUtil) AddYear

func (this TimeUtil) AddYear(date time.Time, iCount int) time.Time

* * 获取指定年后的时间 * @param date 起始时间 * @param iCount 年数 * @return

func (TimeUtil) Current

func (this TimeUtil) Current(formatStr ...string) string

取当前时间

func (TimeUtil) Format

func (this TimeUtil) Format(date time.Time, formatStr string) string

时间格式化

func (TimeUtil) GapDay

func (this TimeUtil) GapDay(t1, t2 interface{}) (day int)

计算日期相差多少天(注意:3到6差距是3而不是4)

func (TimeUtil) GapHour

func (this TimeUtil) GapHour(t1, t2 interface{}) (hour int)

计算日期相差多少小时(注意:3到6差距是3而不是4)

func (TimeUtil) GapMinute

func (this TimeUtil) GapMinute(t1, t2 interface{}) (hour int)

计算日期相差多少分钟(注意:3到6差距是3而不是4)

func (TimeUtil) GapMonth

func (this TimeUtil) GapMonth(t1, t2 interface{}) (month int)

计算日期相差多少月(注意:3到6差距是3而不是4)

func (TimeUtil) GapYear

func (this TimeUtil) GapYear(t1, t2 interface{}) (year int)

计算日期相差多少年(注意:3到6差距是3而不是4)

func (TimeUtil) IsTime

func (this TimeUtil) IsTime(str string) bool

判断字符串是否是日期型

func (TimeUtil) MilliSecond

func (this TimeUtil) MilliSecond() int64

取时间戳(毫秒)

func (TimeUtil) NanoSecond

func (this TimeUtil) NanoSecond() int64

取时间戳(纳秒)

func (TimeUtil) Second

func (this TimeUtil) Second() int64

取时间戳(秒)

func (TimeUtil) ToDate

func (this TimeUtil) ToDate(str string) time.Time

字符串转时间

func (*TimeUtil) ToStr

func (tu *TimeUtil) ToStr() string

func (TimeUtil) Today

func (this TimeUtil) Today(formatStr ...string) string

取今天日期

func (TimeUtil) TodayEd

func (this TimeUtil) TodayEd() string

取今天结束时间

func (TimeUtil) TodaySt

func (this TimeUtil) TodaySt() string

取今天开始时间

type U62Util

type U62Util struct{}

func (U62Util) AnyToDecimal

func (this U62Util) AnyToDecimal(num string, n int) int

任意进制转10进制

func (U62Util) DecimalToAny

func (this U62Util) DecimalToAny(num, n int) string

10进制转任意进制

func (U62Util) FindKey

func (this U62Util) FindKey(in string) int

map根据value找key

func (U62Util) Get

func (this U62Util) Get(sPrefix ...string) string

*

  • 取62位数值(时间戳+2位序号)
  • @param sPrefix 前缀

func (U62Util) To

func (this U62Util) To(num int) string

数字转62位

type UUIDUtil

type UUIDUtil struct{}

func (UUIDUtil) Get

func (ul UUIDUtil) Get() string

func (UUIDUtil) GetLowerCase

func (ul UUIDUtil) GetLowerCase() string

Jump to

Keyboard shortcuts

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