refactor: Replace offset pagination with cursor-based pagination for subscriber listing

- Replace Page and PageSize with Cursor and Limit in ListSubscribersRequest
- Replace Total, Page, and PageSize with NextCursor and HasMore in ListSubscribersResponse
- Add default limit of 20 with max cap of 100 in ListSubscribers
- Replace ListSubscribers call with ListSubscribersCursor in subscriber_crud.go
- Remove unused database import from subscriber_crud.go
- Replace context.Background() with context.Without
This commit is contained in:
nutcas3
2026-05-01 09:06:13 +03:00
parent 444d767ceb
commit 36748d534e
2 changed files with 18 additions and 19 deletions
@@ -53,17 +53,16 @@ type UpdateSubscriberRequest struct {
// ListSubscribersRequest is the query-filter payload for listing subscribers.
type ListSubscribersRequest struct {
Page int `json:"page" query:"page"`
PageSize int `json:"page_size" query:"page_size"`
Cursor string `json:"cursor" query:"cursor"`
Limit int `json:"limit" query:"limit"`
Status models.SubscriberStatus `json:"status" query:"status"`
OrganizationID string `json:"organization_id" query:"organization_id"`
Search string `json:"search" query:"search"`
}
// ListSubscribersResponse is the paginated subscriber list result.
// ListSubscribersResponse is the cursor-paginated subscriber list result.
type ListSubscribersResponse struct {
Subscribers []models.Subscriber `json:"subscribers"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
NextCursor string `json:"next_cursor,omitempty"`
HasMore bool `json:"has_more"`
}