helpers

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

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormatDefault = "2006-01-02 15:04:05"
View Source
const EmptyId = 0

Variables

This section is empty.

Functions

func FindChildrenIdList

func FindChildrenIdList(items []TreeOption, itemId int64) []int64

func FormatDate

func FormatDate(t time.Time, f string) string

func FormatDefaultDate

func FormatDefaultDate(t time.Time) string

func IndexOf

func IndexOf[T comparable](source []T, search T) int

func Int64

func Int64(data interface{}) (int64, bool)

func ParseQueryString

func ParseQueryString(queryString string) map[string]string

ParseQueryString 解析Query字符串

func PasswordHash

func PasswordHash(pwd string) (string, error)

func PasswordVerify

func PasswordVerify(hashedPwd string, pwd string) bool

func Reverse

func Reverse[T any](source []T)

Types

type ITreeNode

type ITreeNode interface {
	GetId() int64
	GetPid() int64
	GetLabel() string
	GetChildren() []ITreeNode
	Get(field string) interface{}
	Append(child ITreeNode)
}

func ToTreeV2

func ToTreeV2(items []ITreeNode) []ITreeNode

type SelectOption

type SelectOption struct {
	Id    int64  `json:"id"`
	Label string `json:"label"`
}

type TreeNode

type TreeNode struct {
	TreeOption
	Children []TreeNode `json:"children"`
}

func ToTree

func ToTree(items []TreeOption) []TreeNode

type TreeNodeV2

type TreeNodeV2 struct {
	Id       int64       `json:"id"`
	Pid      int64       `json:"pid"`
	Label    string      `json:"label"`
	Children []ITreeNode `json:"children"`
}

func (*TreeNodeV2) Append

func (node *TreeNodeV2) Append(child ITreeNode)

func (*TreeNodeV2) Get

func (node *TreeNodeV2) Get(field string) interface{}

func (*TreeNodeV2) GetChildren

func (node *TreeNodeV2) GetChildren() []ITreeNode

func (*TreeNodeV2) GetId

func (node *TreeNodeV2) GetId() int64

func (*TreeNodeV2) GetLabel

func (node *TreeNodeV2) GetLabel() string

func (*TreeNodeV2) GetPid

func (node *TreeNodeV2) GetPid() int64

type TreeOption

type TreeOption struct {
	Id    int64  `json:"id"`
	Pid   int64  `json:"pid"`
	Label string `json:"label"`
}

func FindChildren

func FindChildren(items []TreeOption, itemId int64) []TreeOption

func ToParentLevels

func ToParentLevels(items []TreeOption, itemId int64) []TreeOption

Jump to

Keyboard shortcuts

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