#coding=utf-8

from rest_framework import pagination
from rest_framework.response import Response

import math

class CustomPagination(pagination.PageNumberPagination):
    page_query_param = 'page'
    page_size_query_param = 'limit'
    page_size = 10

    def get_paginated_response(self, data):
        ps = self.get_page_size(self.request)
        return Response({
            'code':0,
            'showCount': ps,
            'totalPage': math.ceil(self.page.paginator.count * 1.0 / ps),
            'totalResult': self.page.paginator.count,
            'currentPage': self.page.number,
            'count': self.page.paginator.count,
            'data': data
        })
