
# -*- coding: utf-8 -*-
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
from rest_framework.viewsets import ViewSet
from django.http import HttpResponse
 
 
tags = ['book']
 
class Book(ViewSet):
    @swagger_auto_schema(
        operation_description="apps get description override",
        manual_parameters=[
            #  openapi.Parameter('cart_id', in_=openapi.IN_QUERY,
            #                    type=openapi.TYPE_INTEGER)
         ],
        security=[], tags=["Demo"], operation_summary='列表')
    def list(self, request):
        return HttpResponse('Hello! Books.')
    
    @swagger_auto_schema(
        operation_description="apps get description override",
        manual_parameters=[
             openapi.Parameter('book_id', in_=openapi.IN_QUERY,
                               type=openapi.TYPE_STRING),
             openapi.Parameter('book_name', in_=openapi.IN_QUERY,
                               type=openapi.TYPE_STRING),
         ],
        security=[], tags=["Demo"], operation_summary='查找')
    def find(self, request):
        print("get_get",request.GET)
        print("get_body",request.body)
        return HttpResponse('find... by book id : %s ,name : %s' % (request.GET['book_id'],request.GET['book_name']))
