request

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package request 提供HTTP请求参数的数据结构定义 本文件定义了通用的请求参数结构,包含按ID查询和批量ID查询的请求格式

Package request 提供HTTP请求参数的数据结构定义 本文件定义了分页查询的请求参数结构,包含分页逻辑和参数验证

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetByIdReqs

type GetByIdReqs struct {
	Id int `json:"id" form:"id"` // 主键ID,用于查询指定的数据实体
}

GetByIdReqs 根据ID查询单个实体的请求结构 该结构体用于接收前端传递的单个ID参数,支持JSON和表单两种数据格式

type GetByIdsReqs

type GetByIdsReqs struct {
	Ids []int `json:"ids" form:"ids"` // ID列表,用于批量查询多个数据实体
}

GetByIdsReqs 根据ID列表批量查询实体的请求结构 该结构体用于接收前端传递的多个ID参数,支持JSON和表单两种数据格式

type Page

type Page struct {
	PageIndex int    `json:"pageIndex" form:"pageIndex"` // 页码,从1开始计数
	PageSize  int    `json:"pageSize" form:"pageSize"`   // 每页大小,控制每页返回的数据条数
	Keyword   string `json:"keyword" form:"keyword"`     // 关键字,用于模糊搜索匹配
}

Page 分页查询通用输入参数结构 该结构体定义了分页查询所需的基本参数,支持页码、每页大小和关键字搜索

func GetPageFromCtx

func GetPageFromCtx(ctx *gin.Context) Page

GetPageFromCtx 从Gin上下文中获取分页参数 该方法从HTTP请求中解析分页参数,并进行参数验证和默认值设置 参数:

  • ctx: Gin上下文,包含HTTP请求信息

返回:

  • Page: 解析后的分页参数,包含验证后的页码和每页大小

func (*Page) Paginate

func (r *Page) Paginate() func(db *gorm.DB) *gorm.DB

Paginate 生成GORM分页查询函数 该方法返回一个GORM查询函数,用于在数据库查询中应用分页逻辑 返回:

  • func(db *gorm.DB) *gorm.DB: GORM分页查询函数

Jump to

Keyboard shortcuts

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