libUtils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

* @desc: 反射相关工具方法 * @Author: lfzxs@qq.com * @Date: 2022/5/10 9:28

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptPassword

func EncryptPassword(password, salt string) string

EncryptPassword 密码加密

func FieldInfoCallBack

func FieldInfoCallBack(item reflect.StructField, value any)

func FileIsExisted

func FileIsExisted(filename string) bool

文件或文件夹是否存在

func FindParentBySonPid

func FindParentBySonPid(list g.List, id int, params ...interface{}) g.List

FindParentBySonPid 有层级关系的数组,通过子级fid查找所有父级数组

func FindSonByParentId

func FindSonByParentId(list g.List, parentId interface{}, parentIndex, idIndex string) g.List

FindSonByParentId 有层级关系的切片,通过父级id查找所有子级id数组 parentId 父级id parentIndex 父级索引名称 idIndex id索引名称

func FindTopParent

func FindTopParent(list g.List, id int64, params ...interface{}) g.Map

FindTopParent *

  • 根据id查询最顶层父级信息
  • @param list 有层级关系的数组
  • @param id 查找的id
  • @param string fpid 父级id键名
  • @param string fid 当前id键名
  • @return g.Map

func ForEachStruct

func ForEachStruct(model any, callback ForEachStructCallBakck)

func GetCityByIp

func GetCityByIp(ip string) string

GetCityByIp 获取ip所属城市

func GetClientIp

func GetClientIp(ctx context.Context) string

GetClientIp 获取客户端IP

func GetDomain

func GetDomain(ctx context.Context) string

GetDomain 获取当前请求接口域名

func GetExt

func GetExt(fileName string) string

获取文件后缀

func GetLocalIP

func GetLocalIP() (ip string, err error)

GetLocalIP 服务端ip

func GetSliceByKey

func GetSliceByKey(args []interface{}, key int, val interface{}) interface{}

GetSliceByKey 获取切片里的值 若为nil 可设置默认值val

func GetStructItemValue

func GetStructItemValue(model any, name string) (any, bool)

取结构体指定名称成员的值

func GetTopPidList

func GetTopPidList(list g.List, parentIndex, idIndex string) *garray.Array

GetTopPidList 获取最顶层 parent Id

func GetType

func GetType(p string) (result string, err error)

GetType 获取文件类型

func GetUserAgent

func GetUserAgent(ctx context.Context) string

GetUserAgent 获取user-agent

func InterfaceToString

func InterfaceToString(value interface{}) string

interface{}转换成字符串

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir 检查文件夹是否存在 如果不存在则新建文件夹

func MkDir

func MkDir(src string) error

MkDir 新建文件夹

func ParentSonSort

func ParentSonSort(list g.List, params ...interface{}) g.List

ParentSonSort 有层级关系的数组,父级-》子级 排序

func ParseFilePath

func ParseFilePath(pathStr string) (fileName string, fileType string)

解析路径获取文件名称及后缀

func PushSonToParent

func PushSonToParent(list g.List, params ...interface{}) g.List

PushSonToParent 有层级关系的数组 ,将子级压入到父级(树形结构)

func SnowflakeId

func SnowflakeId() int64

雪花id

func SnowflakeIdStr

func SnowflakeIdStr() string

雪花id字符串型

func WriteToFile

func WriteToFile(fileName string, content string) error

写入文件

Types

type ForEachStructCallBakck

type ForEachStructCallBakck func(item reflect.StructField, value any)

* * item: 字段项 * value: 项值对象 *

Jump to

Keyboard shortcuts

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