utils

package
v0.0.0-...-9e16cd2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigEnv  = "GVA_CONFIG"
	ConfigFile = "config.yaml"
)
View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

View Source
var (
	IdVerify               = Rules{"ID": {NotEmpty()}}
	ApiVerify              = Rules{"Path": {NotEmpty()}, "Description": {NotEmpty()}, "ApiGroup": {NotEmpty()}, "Method": {NotEmpty()}}
	MenuVerify             = Rules{"Path": {NotEmpty()}, "ParentId": {NotEmpty()}, "Name": {NotEmpty()}, "Component": {NotEmpty()}, "Sort": {Ge("0")}}
	MenuMetaVerify         = Rules{"Title": {NotEmpty()}}
	LoginVerify            = Rules{"CaptchaId": {NotEmpty()}, "Captcha": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {NotEmpty()}}
	RegisterVerify         = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}}
	PageInfoVerify         = Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}}
	CustomerVerify         = Rules{"CustomerName": {NotEmpty()}, "CustomerPhoneData": {NotEmpty()}}
	AutoCodeVerify         = Rules{"Abbreviation": {NotEmpty()}, "StructName": {NotEmpty()}, "PackageName": {NotEmpty()}, "Fields": {NotEmpty()}}
	AuthorityVerify        = Rules{"AuthorityId": {NotEmpty()}, "AuthorityName": {NotEmpty()}, "ParentId": {NotEmpty()}}
	AuthorityIdVerify      = Rules{"AuthorityId": {NotEmpty()}}
	OldAuthorityVerify     = Rules{"OldAuthorityId": {NotEmpty()}}
	ChangePasswordVerify   = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}, "NewPassword": {NotEmpty()}}
	SetUserAuthorityVerify = Rules{"UUID": {NotEmpty()}, "AuthorityId": {NotEmpty()}}
)
View Source
var CustomizeMap = make(map[string]Rules)

Functions

func ArrayToString

func ArrayToString(array []interface{}) string

func AutoInjectionCode

func AutoInjectionCode(filepath string, funcName string, codeData string) error

func BreakPointContinue

func BreakPointContinue(content []byte, fileName string, contentNumber int, contentTotal int, fileMd5 string) (error, string)

func CheckMd5

func CheckMd5(content []byte, chunkMd5 string) (CanUpload bool)

func ClearTable

func ClearTable(db *gorm.DB, tableName string, compareField string, interval string) error

func CreateDir

func CreateDir(dirs ...string) (err error)

func Email

func Email(subject string, body string) error

func EmailTest

func EmailTest(subject string, body string) error

func Eq

func Eq(mark string) string

func ErrorToEmail

func ErrorToEmail(subject string, body string) error

func FileMove

func FileMove(src string, dst string) (err error)

func Ge

func Ge(mark string) string

func GetWriteSyncer

func GetWriteSyncer() (zapcore.WriteSyncer, error)

func Gt

func Gt(mark string) string

func Le

func Le(mark string) string

func Lt

func Lt(mark string) string

func MD5V

func MD5V(str []byte) string

func MakeFile

func MakeFile(fileName string, FileMd5 string) (error, string)

func Ne

func Ne(mark string) string

func NotEmpty

func NotEmpty() string

func PathExists

func PathExists(path string) (bool, error)

func RegisterRule

func RegisterRule(key string, rule Rules) (err error)

func RemoveChunk

func RemoveChunk(FileMd5 string) error

func StructToMap

func StructToMap(obj interface{}) map[string]interface{}

func TrimSpace

func TrimSpace(target interface{})

func Verify

func Verify(st interface{}, roleMap Rules) (err error)

func ZipFiles

func ZipFiles(filename string, files []string, oldForm, newForm string) error

Types

type Cpu

type Cpu struct {
	Cpus  []float64 `json:"cpus"`
	Cores int       `json:"cores"`
}

func InitCPU

func InitCPU() (c Cpu, err error)

type Disk

type Disk struct {
	UsedMB      int `json:"usedMb"`
	UsedGB      int `json:"usedGb"`
	TotalMB     int `json:"totalMb"`
	TotalGB     int `json:"totalGb"`
	UsedPercent int `json:"usedPercent"`
}

func InitDisk

func InitDisk() (d Disk, err error)

type Os

type Os struct {
	GOOS         string `json:"goos"`
	NumCPU       int    `json:"numCpu"`
	Compiler     string `json:"compiler"`
	GoVersion    string `json:"goVersion"`
	NumGoroutine int    `json:"numGoroutine"`
}

func InitOS

func InitOS() (o Os)

type Rrm

type Rrm struct {
	UsedMB      int `json:"usedMb"`
	TotalMB     int `json:"totalMb"`
	UsedPercent int `json:"usedPercent"`
}

func InitRAM

func InitRAM() (r Rrm, err error)

type Rules

type Rules map[string][]string

type RulesMap

type RulesMap map[string]Rules

type Server

type Server struct {
	Os   Os   `json:"os"`
	Cpu  Cpu  `json:"cpu"`
	Rrm  Rrm  `json:"ram"`
	Disk Disk `json:"disk"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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