dto

package
v0.0.0-...-aefe3a2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

type BizRequest

type BizRequest struct {
	BizId int64 `json:"bizId" form:"bizId" uri:"bizId"`
}

BizRequest default business tag reqquest

func (*BizRequest) GetBizId

func (r *BizRequest) GetBizId() int64

func (*BizRequest) ToUrlQuery

func (r *BizRequest) ToUrlQuery() url.Values

type DataPager

type DataPager struct {
	Data interface{} `json:"data"`
	Pager
}

func NewDataPager

func NewDataPager(data interface{}, index, size int, total int64) *DataPager

func (*DataPager) GetTotalRecord

func (p *DataPager) GetTotalRecord() int64

type IBizRequest

type IBizRequest interface {
	GetBizId() int64
	ToUrlQuery() url.Values
}

IBizRequest business tag reqquest

type IPage

type IPage interface {
	GetPageIndex() int32
	GetPageSize() int32
	GetBegin() int
	GetSize() int
	GetAfterID() any
	GetSorts() []ISortField
}

IPage page request

type IRange

type IRange interface {
	GetBeg() int64
	GetEnd() int64
}

IRange range

type ISortField

type ISortField interface {
	GetField() string
	GetIsDesc() bool
}

ISortField sort field

type Page

type Page struct {
	PageIndex int         `json:"page" form:"page" uri:"page" binding:"required,gte=1"`             // currect page no
	AfterId   interface{} `json:"afterId"`                                                          // previous page last id, when sort by pk
	PageSize  int         `json:"pageSize" form:"pageSize" uri:"pageSize" binding:"required,gte=1"` // page size
	Sorts     []string    `json:"sorts" form:"sorts" uri:"sorts"`                                   // eg; field|desc
}

Page default page request

func (*Page) GetAfterID

func (dto *Page) GetAfterID() any

func (*Page) GetBegin

func (dto *Page) GetBegin() int

func (*Page) GetPageIndex

func (dto *Page) GetPageIndex() int32

func (*Page) GetPageSize

func (dto *Page) GetPageSize() int32

func (*Page) GetSize

func (dto *Page) GetSize() int

func (*Page) GetSorts

func (dto *Page) GetSorts() []ISortField

type Pager

type Pager struct {
	Page
	TotalRecord int64 `json:"total"`
	TotalPage   int   `json:"totalPage"`
}

func (*Pager) Paginator

func (p *Pager) Paginator() *Pager

type Range

type Range struct {
	Beg int64 `json:"beg" form:"beg"`
	End int64 `json:"end" form:"end"`
}

Range range

func (*Range) GetBeg

func (i *Range) GetBeg() int64

func (*Range) GetEnd

func (i *Range) GetEnd() int64

type Response

type Response struct {
	BaseResponse
	Data interface{} `json:"data"`
}

func ErrorResponse

func ErrorResponse(err error) *Response

func NewResponse

func NewResponse(data interface{}, ex exception.Exception) *Response

func OkResponse

func OkResponse(data interface{}) *Response

type SortField

type SortField struct {
	Field  string `json:"field" form:"field"`   // order by col
	IsDesc bool   `json:"isDesc" form:"isDesc"` // asc or desc, default is asc
}

SortField default sort field

func (*SortField) GetField

func (r *SortField) GetField() string

func (*SortField) GetIsDesc

func (r *SortField) GetIsDesc() bool

Jump to

Keyboard shortcuts

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