pagex

package
v0.0.0-...-24dfb3c Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewContext

func NewContext(ctx context.Context, pageNum uint64, pageSize uint64, opts ...Option) (context.Context, error)

func WithoutPage

func WithoutPage(ctx context.Context) context.Context

Types

type Option

type Option func(p *Page)

func Count

func Count(count bool) Option

func CountColumn

func CountColumn(countColumn string) Option

func EndTime

func EndTime(t time.Time) Option

func OrderBy

func OrderBy(orderBy string) Option

OrderBy 设置排序字段

func StartTime

func StartTime(t time.Time) Option

type Page

type Page struct {
	// contains filtered or unexported fields
}

func FromContext

func FromContext(ctx context.Context) (*Page, bool)

func FromProto

func FromProto(p *PageProto) *Page

func NewPage

func NewPage(pageNum uint64, pageSize uint64, opts ...Option) (*Page, error)

func (*Page) AsProto

func (p *Page) AsProto() *PageProto

func (*Page) Count

func (p *Page) Count() bool

Count 获取是否包含count查询

func (*Page) CountColumn

func (p *Page) CountColumn() string

CountColumn 获取进行count查询的列名

func (*Page) EndTime

func (p *Page) EndTime() time.Time

EndTime 获取结束时间

func (*Page) Limit

func (p *Page) Limit() uint64

Limit 获取限制行数

func (*Page) Offset

func (p *Page) Offset() uint64

Offset 获取跳过的行数

func (*Page) OrderBy

func (p *Page) OrderBy() string

OrderBy 获取排序字段

func (*Page) PageNum

func (p *Page) PageNum() uint64

PageNum 获取页码

func (*Page) PageSize

func (p *Page) PageSize() uint64

PageSize 获取页面大小

func (*Page) Pages

func (p *Page) Pages() uint64

Pages 获取总页数

func (*Page) SetTotal

func (p *Page) SetTotal(total uint64)

SetTotal 设置总行数, 并计算总页数

func (*Page) StartTime

func (p *Page) StartTime() time.Time

StartTime 获取开始时间

func (*Page) Total

func (p *Page) Total() uint64

Total 获取总行数

type PageProto

type PageProto struct {

	// pageNum 页码,从1开始
	PageNum uint64 `protobuf:"varint,1,opt,name=page_num,json=pageNum,proto3" json:"page_num,omitempty"`
	// pageSize 页面大小
	PageSize uint64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	// offset 跳过的行数
	Offset uint64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"`
	// limit 限制行数
	Limit uint64 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"`
	// total 总行数
	Total uint64 `protobuf:"varint,5,opt,name=total,proto3" json:"total,omitempty"`
	// pages 总页数
	Pages uint64 `protobuf:"varint,6,opt,name=pages,proto3" json:"pages,omitempty"`
	// count 包含count查询
	Count bool `protobuf:"varint,7,opt,name=count,proto3" json:"count,omitempty"`
	// countColumn 进行count查询的列名
	CountColumn string `protobuf:"bytes,8,opt,name=count_column,json=countColumn,proto3" json:"count_column,omitempty"`
	// orderBy 排序,
	OrderBy string `protobuf:"bytes,9,opt,name=order_by,json=orderBy,proto3" json:"order_by,omitempty"`
	// startTime 开始时间
	StartTime *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
	// endTime 结束时间
	EndTime *timestamppb.Timestamp `protobuf:"bytes,11,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
	// contains filtered or unexported fields
}

func (*PageProto) Descriptor deprecated

func (*PageProto) Descriptor() ([]byte, []int)

Deprecated: Use PageProto.ProtoReflect.Descriptor instead.

func (*PageProto) GetCount

func (x *PageProto) GetCount() bool

func (*PageProto) GetCountColumn

func (x *PageProto) GetCountColumn() string

func (*PageProto) GetEndTime

func (x *PageProto) GetEndTime() *timestamppb.Timestamp

func (*PageProto) GetLimit

func (x *PageProto) GetLimit() uint64

func (*PageProto) GetOffset

func (x *PageProto) GetOffset() uint64

func (*PageProto) GetOrderBy

func (x *PageProto) GetOrderBy() string

func (*PageProto) GetPageNum

func (x *PageProto) GetPageNum() uint64

func (*PageProto) GetPageSize

func (x *PageProto) GetPageSize() uint64

func (*PageProto) GetPages

func (x *PageProto) GetPages() uint64

func (*PageProto) GetStartTime

func (x *PageProto) GetStartTime() *timestamppb.Timestamp

func (*PageProto) GetTotal

func (x *PageProto) GetTotal() uint64

func (*PageProto) ProtoMessage

func (*PageProto) ProtoMessage()

func (*PageProto) ProtoReflect

func (x *PageProto) ProtoReflect() protoreflect.Message

func (*PageProto) Reset

func (x *PageProto) Reset()

func (*PageProto) String

func (x *PageProto) String() string

Jump to

Keyboard shortcuts

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