request

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package request provides request parameter parsing and helper types.

It includes pagination, CRUD query parameters, JWT context extraction, and helper types for standardizing Gin request handling.

Index

Constants

View Source
const ContextLoginUserKey = "__login_user__"
View Source
const ContextPublicRequestKey = "__public_request__"

Variables

This section is empty.

Functions

func JWTLoginUserId

func JWTLoginUserId(ctx *gin.Context) int

获取 JWT 中存储的用户信息

Types

type CRUDCondition

type CRUDCondition struct {
	Column string `json:"c"`
	Type   uint8  `json:"t"` // TODO 是否只在后台定义搜索类型,前端不需要这个字段?
	Value  string `json:"v"`
}

type CRUDRequest

type CRUDRequest struct {
	Query    []CRUDCondition `json:"query,omitempty"`
	Sort     string          `json:"sort,omitempty"`
	Page     int64           `json:"page,omitempty"`
	PageSize int64           `json:"page_size,omitempty"`
	Id       string          `json:"id,omitempty"`
	Ids      []string        `json:"ids,omitempty"`
}

func PublicRequestCrud

func PublicRequestCrud(ctx *gin.Context) CRUDRequest

type PageInfo

type PageInfo struct {
	Page     int64 `json:"page,omitempty"`
	PageSize int64 `json:"page_size,omitempty"`
	Total    int64 `json:"total,omitempty"`
}

type PageQuery

type PageQuery[T any] struct {
	Query    T        `json:"query"`
	PageInfo PageInfo `json:"page_info"`
}

func PageRequest

func PageRequest[T any](ctx *gin.Context, query T) (PageQuery[T], error)

type PublicPageRequest

type PublicPageRequest struct {
	Query map[string]interface{} `json:"query,omitempty"`
	Sort  []string               `json:"sort,omitempty"`
	Id    string                 `json:"id,omitempty"`
	Ids   []any                  `json:"ids,omitempty"`
	PageInfo
}

func PublicRequest

func PublicRequest(ctx *gin.Context) PublicPageRequest

Jump to

Keyboard shortcuts

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