viewBook.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. from drf_yasg import openapi
  3. from drf_yasg.utils import swagger_auto_schema
  4. from rest_framework.viewsets import ViewSet
  5. from django.http import HttpResponse
  6. tags = ['book']
  7. class Book(ViewSet):
  8. @swagger_auto_schema(
  9. operation_description="apps get description override",
  10. manual_parameters=[
  11. # openapi.Parameter('cart_id', in_=openapi.IN_QUERY,
  12. # type=openapi.TYPE_INTEGER)
  13. ],
  14. security=[], tags=["Demo"], operation_summary='列表')
  15. def list(self, request):
  16. return HttpResponse('Hello! Books.')
  17. @swagger_auto_schema(
  18. operation_description="apps get description override",
  19. manual_parameters=[
  20. openapi.Parameter('book_id', in_=openapi.IN_QUERY,
  21. type=openapi.TYPE_STRING),
  22. openapi.Parameter('book_name', in_=openapi.IN_QUERY,
  23. type=openapi.TYPE_STRING),
  24. ],
  25. security=[], tags=["Demo"], operation_summary='查找')
  26. def find(self, request):
  27. print("get_get",request.GET)
  28. print("get_body",request.body)
  29. return HttpResponse('find... by book id : %s ,name : %s' % (request.GET['book_id'],request.GET['book_name']))