Commit 167077c8 authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'dev'

tag search add page count

See merge request !50
parents 992cf45c 5085d20d
......@@ -3,7 +3,7 @@
# __author__ = "chenwei"
# Date: 2018/11/17
from utils.base import APIView
from utils.base import APIView, get_offset_count
class GroupSearchView(APIView):
......@@ -45,10 +45,11 @@ class UserSearchView(APIView):
class TagSearchView(APIView):
def get(self, request):
offset, count = get_offset_count(request)
name = request.GET.get('name')
platform = request.GET.get('platform')
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:
raise e
return {
......
......@@ -348,3 +348,19 @@ class ClientDefaultArgs(LazyAttrDict):
def get_device_id(self):
device_id = self.device_id or self.idfv or self.idfa
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