package common import "math" type PageRequest[T any] struct { Page Pagination `json:"page"` OrderBy string `json:"order_by"` Desc bool `json:"desc"` Query T `json:"query"` } type PageResponse[T any] struct { PageNum int64 `json:"pageNum"` PageSize int64 `json:"pageSize"` Pages int `json:"pages"` Total int `json:"total"` Records []T `json:"records"` } func Page[T any](page Pagination, total int64, records []T) *PageResponse[T] { return &PageResponse[T]{ PageNum: page.PageNum, PageSize: page.PageSize, Pages: int(math.Ceil(float64(total) / float64(page.PageSize))), Total: int(total), Records: records, } }