utils

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyProfileUpdates added in v0.0.21

func ApplyProfileUpdates(user *model.User, req *model.UpdateProfileReq)

ApplyProfileUpdates 应用可编辑的用户资料字段

func BuildUserForCreate added in v0.0.21

func BuildUserForCreate(req *model.UserSignUpReq, hashedPassword string) *model.User

BuildUserForCreate 将注册请求转换为可持久化的用户实体

func ComparePassword added in v0.0.21

func ComparePassword(hashedPassword, rawPassword string) error

ComparePassword 对比明文密码与密文密码

func ExtractClaims added in v0.0.21

func ExtractClaims(ctx *gin.Context) (pkgutils.UserClaims, error)

ExtractClaims 从 gin 上下文安全提取登录用户信息

func FormatBytes

func FormatBytes(bytes uint64, unit string) string

FormatBytes 格式化字节大小

func GetDiskUsagePercentage

func GetDiskUsagePercentage(s *model.System) float64

GetDiskUsagePercentage 获取磁盘使用率百分比

func GetMemoryUsagePercentage

func GetMemoryUsagePercentage(s *model.System) float64

GetMemoryUsagePercentage 获取内存使用率百分比

func GetUptimeFormatted

func GetUptimeFormatted(s *model.System) string

GetUptimeFormatted 获取格式化的运行时间

func HashPassword added in v0.0.21

func HashPassword(password string) (string, error)

HashPassword 对密码进行统一校验与加密

func RequireNonEmpty added in v0.0.21

func RequireNonEmpty(value, field string) error

RequireNonEmpty 校验字符串是否为空

func RequirePositiveID added in v0.0.21

func RequirePositiveID(id int, field string) error

RequirePositiveID 校验 ID 是否大于零

func ToResponse

func ToResponse(s *model.System) *model.SystemInfoResponse

ToResponse 转换为响应格式

Types

This section is empty.

Jump to

Keyboard shortcuts

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