Commit 5085d20d authored by 王浩's avatar 王浩

tag search add page count

parent 992cf45c
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/17 # Date: 2018/11/17
from utils.base import APIView from utils.base import APIView, get_offset_count
class GroupSearchView(APIView): class GroupSearchView(APIView):
...@@ -45,10 +45,11 @@ class UserSearchView(APIView): ...@@ -45,10 +45,11 @@ class UserSearchView(APIView):
class TagSearchView(APIView): class TagSearchView(APIView):
def get(self, request): def get(self, request):
offset, count = get_offset_count(request)
name = request.GET.get('name') name = request.GET.get('name')
platform = request.GET.get('platform') platform = request.GET.get('platform')
try: try:
data = self.rpc['venus/sun/tag/search'](name=name, platform=platform).unwrap() data = self.rpc['venus/sun/tag/search'](offset=offset, count=count, name=name, platform=platform).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return { return {
......
...@@ -348,3 +348,19 @@ class ClientDefaultArgs(LazyAttrDict): ...@@ -348,3 +348,19 @@ class ClientDefaultArgs(LazyAttrDict):
def get_device_id(self): def get_device_id(self):
device_id = self.device_id or self.idfv or self.idfa device_id = self.device_id or self.idfv or self.idfa
return device_id return device_id
def get_offset_count(request):
try:
page = int(request.GET.get('page', 1))
except:
page = 1
try:
count = int(request.GET.get('count', 10))
except:
count = 10
offset = count * (page-1)
return offset, count
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment