misc

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextBlack = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextPurple
	TextCyan
	TextWhite
)

Variables

This section is empty.

Functions

func AesCBCDecrypt

func AesCBCDecrypt(rawData string, key []byte) (string, error)

func AesCBCEncrypt

func AesCBCEncrypt(rawData, key []byte) (string, error)

func ColorText

func ColorText(color int, str string) string

func CryptoJSAESDecrypt

func CryptoJSAESDecrypt(rawData string, key []byte) (result string, err error)

CryptoJS解密(适配CryptoJS, CBC+pKCS7)

func CryptoJSAESEncrypt

func CryptoJSAESEncrypt(rawData string, key []byte) (result string, err error)

CryptoJS加密(适配CryptoJS, CBC+pKCS7)

func DBModel2View

func DBModel2View[Source base.IDBModel, DEST base.IViewModel](model Source) (result DEST, err error)

func DBModelList2ViewList

func DBModelList2ViewList[Source base.IDBModel, DEST base.IViewModel](models []Source) (result []DEST, err error)

func GetExecutorContext

func GetExecutorContext(executor string) context.Context

func GetModelDBFieldNames

func GetModelDBFieldNames(module interface{}) (result map[string]*Field, err error)

通过反射转换,反向通过字段Tag信息查找字段名,然后转换成实际数据库字段名称,此方法在系统启动时运行,不影响运行效率

func GetObjProperty

func GetObjProperty(obj interface{}, fieldName string) (interface{}, error)

func GetRndUnUsePortNumber

func GetRndUnUsePortNumber() (result int, err error)

GetRndUnUsePortNumber 获取未使用随机端口

func Md5Hash

func Md5Hash(source string) string

func NewGuid

func NewGuid() (result uuid.UUID)

func NewGuidString

func NewGuidString() (result string)

func NewHexId

func NewHexId() (result string)

func NewId

func NewId() (result uint64)

func PathExists

func PathExists(path string) (bool, error)

func PortCanUse

func PortCanUse(portNumber int) bool

PortCanUse 检测TCP端口是否可用

func PrintErrorInfo

func PrintErrorInfo(str string)

func PrintInfo

func PrintInfo(str string)

func ProcessSwaggerTemplate

func ProcessSwaggerTemplate(template string, placeholder string, realPath string) (result string)

处理Swagger模版,替换其中接口访问占位符为当前挂载路径

func ReadBody

func ReadBody(ctx iris.Context, vModel base.IViewModel) (err error)

func SHA1

func SHA1(data string) string

对字符串进行SHA1哈希

func ServiceLoadInfo

func ServiceLoadInfo(serviceName string, enable bool, loadTime time.Time)

func WriteJson

func WriteJson(ctx iris.Context, v interface{})

func WriteWithFileWrite

func WriteWithFileWrite(filePath, fileName, content string)

Types

type Field

type Field struct {
	Type           string
	Caption        string
	ModelFieldName string
	DBFieldName    string
}

Jump to

Keyboard shortcuts

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