UPDATE: Change cursor to offset, bc FE dk implement
All checks were successful
Build and Release / release (push) Successful in 1m3s
All checks were successful
Build and Release / release (push) Successful in 1m3s
This commit is contained in:
@@ -13,18 +13,45 @@ type CommonResponse struct {
|
||||
}
|
||||
|
||||
type JWTClaims struct {
|
||||
UId string `json:"uid"`
|
||||
Roles []constants.Role `json:"roles"`
|
||||
TokenVersion int32 `json:"token_version"`
|
||||
UId string `json:"uid"`
|
||||
Roles []constants.Role `json:"roles"`
|
||||
TokenVersion int32 `json:"token_version"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
type PaginatedResponse struct {
|
||||
Data any `json:"data"`
|
||||
Status bool `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Pagination struct {
|
||||
NextCursor string `json:"next_cursor"`
|
||||
HasMore bool `json:"has_more"`
|
||||
} `json:"pagination"`
|
||||
type PaginationMeta struct {
|
||||
CurrentPage int `json:"current_page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalRecords int64 `json:"total_records"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
type PaginatedResponse struct {
|
||||
Status bool `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
Pagination *PaginationMeta `json:"pagination"`
|
||||
}
|
||||
|
||||
func BuildPaginatedResponse(data any, totalRecords int64, page int, limit int) *PaginatedResponse {
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if limit < 1 {
|
||||
limit = 10
|
||||
}
|
||||
|
||||
totalPages := int((totalRecords + int64(limit) - 1) / int64(limit))
|
||||
|
||||
return &PaginatedResponse{
|
||||
Status: true,
|
||||
Message: "Success",
|
||||
Data: data,
|
||||
Pagination: &PaginationMeta{
|
||||
CurrentPage: page,
|
||||
PageSize: limit,
|
||||
TotalRecords: totalRecords,
|
||||
TotalPages: totalPages,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user