Documentation ¶
Overview ¶
Package utils @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 13:40
Package utils @program: arco-design-pro-gin @author: [lliuhuan](https://github.com/lliuhuan) @create: 2021-12-10 13:37
Index ¶
- Constants
- func BaseValidator(obj interface{}, c *gin.Context) (string, error)
- func BaseValidatorQuery(obj interface{}, c *gin.Context) (string, error)
- func BaseValidatorUri(obj interface{}, c *gin.Context) (string, error)
- func GetClaims(c *gin.Context) (*systemReq.CustomClaims, error)
- func GetUserAuthorityId(c *gin.Context) string
- func GetUserID(c *gin.Context) uint
- func GetUserInfo(c *gin.Context) *systemReq.CustomClaims
- func GetUserUuid(c *gin.Context) uuid.UUID
- func GetWriteSyncer(file string) zapcore.WriteSyncer
- func MD5V(str []byte, b ...byte) string
- func PathExists(path string) (bool, error)
- func Reload() error
- func StructToMap(obj interface{}) map[string]interface{}
- type Cpu
- type Disk
- type JWT
- func (j *JWT) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims
- func (j *JWT) CreateToken(claims request.CustomClaims) (string, error)
- func (j *JWT) CreateTokenByOldToken(oldToken string, claims request.CustomClaims) (string, error)
- func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error)
- type Os
- type Process
- type Rrm
- type Server
Constants ¶
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
const (
ConfigEnv = "ADP_CONFIG"
)
Variables ¶
This section is empty.
Functions ¶
func GetClaims ¶
func GetClaims(c *gin.Context) (*systemReq.CustomClaims, error)
GetClaims 根据token获取claims信息
func GetUserAuthorityId ¶
GetUserAuthorityId 从Gin的Context中获取从jwt解析出来的用户角色id
func GetUserInfo ¶
func GetUserInfo(c *gin.Context) *systemReq.CustomClaims
GetUserInfo 从Gin的Context中获取从jwt解析出来的用户角色id
func GetUserUuid ¶
GetUserUuid 从Gin的Context中获取从jwt解析出来的用户UUID
func GetWriteSyncer ¶
func GetWriteSyncer(file string) zapcore.WriteSyncer
GetWriteSyncer zap logger中加入file-rotatelogs @author: [lliuhuan](https://github.com/lliuhuan) @function: GetWriteSyncer @description: zap logger中加入file-rotatelogs @return: zapcore.WriteSyncer, error
func MD5V ¶
MD5V 简单md5加密 @author: [lliuhuan](https://github.com/lliuhuan) @function: MD5V @description: md5加密 @param: str []byte @return: string
func PathExists ¶
PathExists 文件目录是否存在 @author: [lliuhuan](https://github.com/lliuhuan) @function: PathExists @description: 文件目录是否存在 @param: path string @return: bool, error
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
StructToMap 利用反射将结构体转化为map @author: [lliuhuan](https://github.com/lliuhuan) @function: StructToMap @description: 利用反射将结构体转化为map @param: obj interface{} @return: map[string]interface{}
Types ¶
type Cpu ¶
func InitCPU ¶
InitCPU CPU信息 @author: [lliuhuan](https://github.com/lliuhuan) @function: InitCPU @description: CPU信息 @return: 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 ¶
InitDisk 硬盘信息 @author: [lliuhuan](https://github.com/lliuhuan) @function: InitDisk @description: 硬盘信息 @return: d Disk, err error
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateClaims ¶
func (j *JWT) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims
CreateClaims 创建token数据
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims request.CustomClaims) (string, error)
CreateToken 创建一个token
func (*JWT) CreateTokenByOldToken ¶
CreateTokenByOldToken 旧token 换新token 使用归并回源避免并发问题
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error)
ParseToken 解析 token
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)
InitOS OS信息 @author: [lliuhuan](https://github.com/lliuhuan) @function: InitOS @description: OS信息 @return: o Os, err error
type Process ¶
type Process struct { CpuPercent float64 `json:"cpuPercent"` OneCpuPercent float64 `json:"oneCpuPercent"` ThreadCount int `json:"threadCount"` GoroutineCount int `json:"goroutineCount"` Memory float32 `json:"memory"` }