2023-12-08 13:33:09 +00:00
|
|
|
package helper
|
|
|
|
|
2024-01-04 15:32:10 +00:00
|
|
|
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
|
|
|
|
}
|
2024-01-04 15:32:10 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|