# Path: vodmanagement/pagination.py
# class CustomPaginator(Paginator):
#     def __init__(self, current_page=0, per_pager_num=5, *args, **kwargs):
#         # 当前页
#         self.current_page = int(current_page)
#         # 最多显示的页码数量
#         self.per_pager_num = int(per_pager_num)
#         super(CustomPaginator, self).__init__(*args, **kwargs)
# 
#     def pager_num_range(self):
#         if self.num_pages < self.per_pager_num:
#             return list(range(1, self.num_pages + 1))
#         # 如果页数特别多
#         part = int(self.per_pager_num / 2)
#         if self.current_page <= part:
#             return list(range(1, self.per_pager_num + 1))
#         if (self.current_page + part) > self.num_pages:
#             return list(range(self.num_pages - self.per_pager_num + 1, self.num_pages + 1))
#         return list(range(self.current_page - part, self.current_page + part + 1))


from rest_framework.pagination import *
from vodmanagement.pagination import CustomPaginator
        return list(self.page)


class RecordPageNumberPagination(PageNumberPagination):
    page_size = 12

    def get_paginated_response(self, data):
        return Response(OrderedDict([
            ('count', self.page.paginator.count),
            ('next', self.get_next_link()),
            ('previous', self.get_previous_link()),
            ('cur_page', self.page.number),
            ('num_pages', self.paginator.num_pages),
            ('page_range', self.paginator.pager_num_range()),
            ('results', data)
        ]))

    def paginate_queryset(self, queryset, request, view=None):
        """
        Paginate a queryset if required, either returning a
        page object, or `None` if pagination is not configured for this view.
        """

        page_size = self.get_page_size(request)
        if not page_size:
            return None
        cur_page = request.query_params.get(self.page_query_param)
        if not cur_page:
            cur_page = 1
        # paginator = self.django_paginator_class(queryset, page_size)

# Path: vodmanagement/pagination.py
# class CustomPaginator(Paginator):
#     def __init__(self, current_page=0, per_pager_num=5, *args, **kwargs):
#         # 当前页
#         self.current_page = int(current_page)
#         # 最多显示的页码数量
#         self.per_pager_num = int(per_pager_num)
#         super(CustomPaginator, self).__init__(*args, **kwargs)
# 
#     def pager_num_range(self):
#         if self.num_pages < self.per_pager_num:
#             return list(range(1, self.num_pages + 1))
#         # 如果页数特别多
#         part = int(self.per_pager_num / 2)
#         if self.current_page <= part:
#             return list(range(1, self.per_pager_num + 1))
#         if (self.current_page + part) > self.num_pages:
#             return list(range(self.num_pages - self.per_pager_num + 1, self.num_pages + 1))
#         return list(range(self.current_page - part, self.current_page + part + 1))


# Path: vodmanagement/api/pagination.py
from rest_framework.pagination import *
from vodmanagement.pagination import CustomPaginator

        return list(self.page)


class RecordPageNumberPagination(PageNumberPagination):
    page_size = 12

    def get_paginated_response(self, data):
        return Response(OrderedDict([
            ('count', self.page.paginator.count),
            ('next', self.get_next_link()),
            ('previous', self.get_previous_link()),
            ('cur_page', self.page.number),
            ('num_pages', self.paginator.num_pages),
            ('page_range', self.paginator.pager_num_range()),
            ('results', data)
        ]))

    def paginate_queryset(self, queryset, request, view=None):
        """
        Paginate a queryset if required, either returning a
        page object, or `None` if pagination is not configured for this view.
        """

        page_size = self.get_page_size(request)
        if not page_size:
            return None
        cur_page = request.query_params.get(self.page_query_param)
        if not cur_page:
            cur_page = 1
        # paginator = self.django_paginator_class(queryset, page_size)

        self.paginator = CustomPaginator(cur_page, 5, queryset, page_size)