utils

package
v0.0.0-...-214ca0d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePassword

func GeneratePassword(password string) string

GeneratePassword - crypt password

func GenerateRandomString

func GenerateRandomString(n int, runes string) string

func GenerateUUID

func GenerateUUID() string

GenerateSecurityToken - func generate uuid4 based security token without "-"

func GetCurrentPage

func GetCurrentPage(pageStr string) (currentPage int, err error)

func GetDatePtr

func GetDatePtr(year int, month time.Month, day int, hour int, min int, sec int, nsec int, loc *time.Location) *time.Time

GetDatePtr - get date as pointer

func GetFileChecksumSHA512

func GetFileChecksumSHA512(filepath string) (string, error)

func GetFileReaderChecksumSHA512

func GetFileReaderChecksumSHA512(reader io.Reader) (string, error)

func GetUnixDatePtr

func GetUnixDatePtr(nsec int64) *time.Time

GetUnixDatePtr - get date, GMT timezone, milliseconds since unix epoch

func JSONListTagged

func JSONListTagged(obj interface{}, tag string) []byte

JSONListTagged - get tagged objects list

func JSONPrettyPrint

func JSONPrettyPrint(in string) string

JSONPrettyPrint - udela hezky JSON

func ObjectPrettyPrint

func ObjectPrettyPrint(obj interface{}) string

ObjectPrettyPrint - tady udelej hezke zobrazeni objektu skrz JSON

func ParseDatePtr

func ParseDatePtr(layout string, value string) *time.Time

func ValidatePassword

func ValidatePassword(hashedPassword string, password string) bool

ValidatePassword - validate password

@hashedPassowrd: password stored at db, hashed form
@password: password from form, not hashed

Types

type Pagination

type Pagination struct {
	Page         int64 `json:"page" jsonList:"page"`                 // current page
	ItemsPerPage int64 `json:"itemsPerPage" jsonList:"itemsPerPage"` // Count of items per page
	PageStart    int64 `json:"pageStart" jsonList:"pageStart"`       // First page
	PageStop     int64 `json:"pageStop" jsonList:"pageStop"`         // Last page
	PageCount    int64 `json:"pageCount" jsonList:"pageCount"`       // Pages count
	PageNext     int64 `json:"pageNext" jsonList:"pageNext"`         // Next page
	PagePrev     int64 `json:"pagePrev" jsonList:"pagePrev"`         // Previous page
	ItemsCount   int64 `json:"totalItems" jsonList:"totalItems"`     // Count of all items in dataset
}

Pagination - json is optimized for VuetifyJS

func (*Pagination) GetLimits

func (me *Pagination) GetLimits(currentPage int64) (offset int64, limit int64, err error)

GetLimits - Vraci limity pro databazi

func (*Pagination) RecountValuesFromPage

func (me *Pagination) RecountValuesFromPage() (err error)

RecountValuesFromPage - method recount values from page, itemsPerPage and itemsCount

func (*Pagination) SetValuesFromPage

func (me *Pagination) SetValuesFromPage(currentPage int64, itemsPerPage int64, itemsCount int64)

SetValuesFromPage - set all values from current page and items per page AND recount it

type QueryOptions

type QueryOptions struct {
	SortBy    []string
	SortDesc  []bool
	GroupBy   []string
	GroupDesc []bool
	MultiSort bool
	MustSort  bool
}

QueryOptions - object

type ResponseWithPagination

type ResponseWithPagination struct {
	Response         interface{}
	PaginationObject Pagination
}

ResponseWithPagination - Get response data with pagination object

Jump to

Keyboard shortcuts

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