helper

package
v0.0.0-...-e4b8de6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDir

func CreateDir(dirs ...string)

func Decryption

func Decryption(str string, keys ...string) (string, error)

func Encryption

func Encryption(str string, keys ...string) (string, error)

func FileMd5

func FileMd5(data []byte) string

FileMd5 File MD5

func FormatData

func FormatData[T any](data []T, call func(item T, index int) map[string]any, page *Pagination) ([]map[string]any, map[string]any)

func FormatFileSize

func FormatFileSize(fileSize int64) (size string)

FormatFileSize Format File Size

func GetTreeNode

func GetTreeNode(data any, id uint, idField string, sonField string) map[string]any

func GetUuid

func GetUuid() (string, error)

GetUuid Get UUID

func HashEncode

func HashEncode(content string) string

HashEncode Ciphertext Encryption

func HashVerify

func HashVerify(hashedPwd string, password string) bool

HashVerify Ciphertext Verification

func InTimeSpan

func InTimeSpan(start, end, check time.Time, includeStart, includeEnd bool) bool

InTimeSpan Range Time Query

func IsExist

func IsExist(f string) bool

IsExist Determine if Directory/File Exists

func LcFirst

func LcFirst(str string) string

LcFirst Lowercase the First Letter

func Md5

func Md5(text string) string

Md5 Generate 32-bit MD5

func PageLimit

func PageLimit(page int, total int, limit int) (int, int)

PageLimit Calculation

func Paginate

func Paginate(pagination *Pagination) func(db *gorm.DB) *gorm.DB

func RandString

func RandString(len int) string

RandString Random Characters

func Round

func Round(val float64, precision int) float64

Round Keep Decimal Places

func SliceToTree

func SliceToTree(data []map[string]any, idField string, pidField string, sonField string) []map[string]any

func UcFirst

func UcFirst(str string) string

UcFirst Uppercase the First Letter

Types

type Pagination

type Pagination struct {
	PageSize int   `json:"pageSize,omitempty"`
	Page     int   `json:"page,omitempty"`
	Total    int64 `json:"total"`
	Pages    int   `json:"pages"`
}

func NewPagination

func NewPagination(page, pageSize int) *Pagination

func (*Pagination) GetLimit

func (p *Pagination) GetLimit() int

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() int

func (*Pagination) GetPage

func (p *Pagination) GetPage() int

Jump to

Keyboard shortcuts

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