From 34aaf22650f2c6632feb0b431e10cf64d61a169d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 27 Feb 2024 09:14:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20base=20viewset=E5=A2=9E=E5=8A=A0query?= =?UTF-8?q?=E5=AE=9A=E5=88=B6=E8=BF=94=E5=9B=9E=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/utils/viewsets.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/utils/viewsets.py b/apps/utils/viewsets.py index 6870db08..ea51fdb2 100755 --- a/apps/utils/viewsets.py +++ b/apps/utils/viewsets.py @@ -16,6 +16,7 @@ from apps.utils.queryset import get_child_queryset2, get_child_queryset_u from apps.utils.serializers import PkSerializer, ComplexSerializer from rest_framework.throttling import UserRateThrottle from drf_yasg.utils import swagger_auto_schema +from drf_yasg import openapi from apps.utils.decorators import idempotent from django.db import transaction import json @@ -200,6 +201,13 @@ class CustomModelViewSet(BulkCreateModelMixin, BulkUpdateModelMixin, ListModelMi if v not in ALL_PERMS and v != '*': ALL_PERMS.append(v) + @swagger_auto_schema(manual_parameters=[ + openapi.Parameter(name="query", in_=openapi.IN_QUERY, description="定制返回数据", + type=openapi.TYPE_STRING, required=False), + ]) + def list(self, request, *args, **kwargs): + return super().list(request, *args, **kwargs) + @swagger_auto_schema(request_body=ComplexSerializer, responses={200: {}}) @action(methods=['post'], detail=False, perms_map={'post': '*'}) def cquery(self, request):