wp-go/helper/others.go

27 lines
503 B
Go
Raw Normal View History

2023-12-08 13:33:09 +00:00
package helper
import "context"
type Pagination[T any] interface {
SetData(ctx context.Context, data []T)
GetData(ctx context.Context) []T
TotalRaws(ctx context.Context) int
}
2023-12-08 13:33:09 +00:00
type PaginationData[T any] struct {
Data []T
TotalRaw int
}
func (p *PaginationData[T]) SetData(ctx context.Context, data []T) {
p.Data = data
}
func (p *PaginationData[T]) GetData(ctx context.Context) []T {
return p.Data
}
func (p *PaginationData[T]) TotalRaws(ctx context.Context) int {
return p.TotalRaw
}