component

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoundPageSize added in v0.0.9

func BoundPageSize(pageSize int) int

func BoundPageSizeWithRange added in v0.0.9

func BoundPageSizeWithRange[T cmp.Ordered](pageSize T, minN, maxN T) T

func BuildCanonicalHref added in v0.0.9

func BuildCanonicalHref(c *gin.Context) string

func CheckUserPermission added in v0.1.1

func CheckUserPermission(userEntity *users.EntityComplete, action string) (error, int)

CheckUserPermission 统一检查用户操作权限(封禁状态、邮箱验证等)

func GetBaseUri added in v0.0.9

func GetBaseUri(c *gin.Context) string

func GetHost added in v0.0.9

func GetHost(c *gin.Context) string

func GetLoginUser added in v0.0.9

func GetLoginUser(c *gin.Context) *vo.UserInfoShow

func GetUserShowByUserId added in v0.0.9

func GetUserShowByUserId(userId uint64) *vo.UserInfoShow

func LoginUserId added in v0.0.9

func LoginUserId(c *gin.Context) uint64

func SendAEmail4User added in v0.0.9

func SendAEmail4User(userEntity *users.EntityComplete) error

func ValidateEmailDomain added in v0.1.1

func ValidateEmailDomain(email string) error

ValidateEmailDomain 验证邮箱域名是否符合白名单限制

func ValidatePassword added in v0.0.9

func ValidatePassword(password string, minLength int) error

ValidatePassword 验证密码复杂度

func ValidateUsername added in v0.0.9

func ValidateUsername(username string) bool

Types

type BetterRequest

type BetterRequest[T any] struct {
	Params T
	UserId uint64

	GinContext *gin.Context
	// contains filtered or unexported fields
}

func (*BetterRequest[T]) GetParams

func (r *BetterRequest[T]) GetParams() T

func (*BetterRequest[T]) GetUser

func (r *BetterRequest[T]) GetUser() (users.EntityComplete, error)

type DataMap

type DataMap map[string]any

type Null

type Null struct {
}

type NullRequest

type NullRequest BetterRequest[Null]

type Page

type Page[T any] struct {
	List  []T   `json:"list"`
	Page  int   `json:"page"`
	Size  int   `json:"size"`
	Total int64 `json:"total"`
}

type Response

type Response struct {
	Code int
	Data ResultStruct
}

func BuildResponse

func BuildResponse(code int, data ResultStruct) Response

func FailResponse

func FailResponse(msg any) Response

func SuccessPage

func SuccessPage[T any](list []T, page, size int, total int64) Response

func SuccessResponse

func SuccessResponse(data any) Response

type ResultStruct

type ResultStruct struct {
	Msg    any    `json:"msg"`
	Result any    `json:"result"`
	Code   Status `json:"code"`
}

func FailData

func FailData(msg any) ResultStruct

func SuccessData

func SuccessData(data any) ResultStruct

type Status

type Status int
const (
	SUCCESS Status = iota // 成功
	FAIL                  // 失败
)

Jump to

Keyboard shortcuts

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