You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from django.http import JsonResponse
|
|
|
|
from django.db.models import Q
|
|
|
|
from rest_framework import viewsets, permissions, status
|
|
|
|
from update.models import Cinema
|
|
|
|
from update.serializers import CinemaSerializer
|
|
|
|
from rest_framework.views import APIView
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
|
|
|
|
|
|
|
class CinemaViewSet(viewsets.ModelViewSet):
|
|
|
|
# 接口文档的中文注释
|
|
|
|
"""
|
|
|
|
create: 添加测试影院
|
|
|
|
list: 获取测试影院列表
|
|
|
|
retrieve: 获取某个影院的信息
|
|
|
|
update: 更新某个影院的信息
|
|
|
|
delete: 删除指定影院
|
|
|
|
"""
|
|
|
|
queryset = Cinema.objects.all()
|
|
|
|
serializer_class = CinemaSerializer
|
|
|
|
permission_classes = (permissions.IsAuthenticated,)
|
|
|
|
|
|
|
|
|
|
|
|
class CinemaSearchAPIView(APIView):
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
query_params = request.query_params.dict()
|
|
|
|
print(query_params)
|
|
|
|
query_data = Cinema.objects.filter(
|
|
|
|
Q(ip__contains=query_params.get('ip')) & Q(sys_ver__icontains=query_params.get('version')))
|
|
|
|
serializer = CinemaSerializer(instance=query_data, many=True)
|
|
|
|
return Response(serializer.data, status=status.HTTP_200_OK)
|