Commit f8a99531 authored by Davve's avatar Davve

增加过滤筛选

parent 7032fb40
......@@ -10,11 +10,11 @@ class PickListView(APIView):
def get(self, request):
page = request.GET.get('page', 1)
limit = request.GET.get('limit', 10)
filter = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/pick/get'](offset=page, limit=limit).unwrap()
data = self.rpc['venus/community/pick/get'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e:
raise e
print(data)
return data
def post(self, request):
......
......@@ -6,7 +6,7 @@
# Date : 16/03/25 13:15:41
# Desc : view 等 基类
#
import json
from functools import wraps
from distutils.version import LooseVersion
from django.views.decorators.csrf import csrf_exempt
......@@ -292,6 +292,27 @@ class APIView(View):
start_num = (page - 1) * page_size
return start_num
def make_pair(self, data):
val = data.pop('value', '')
key = data.pop('key', '')
if key and key not in ['id']:
key += '__contains'
if key:
data.update({key: val})
for key in list(data.keys()):
if data.get(key) == '':
del data[key]
return data
def handle_filter(self, filter):
if not isinstance(filter, str):
return {}
filter_data = json.loads(filter)
return self.make_pair(filter_data)
class ClientDefaultArgs(LazyAttrDict):
"""
......
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