feat: base viewset增加query定制返回参数
This commit is contained in:
parent
9d48575be4
commit
34aaf22650
|
@ -16,6 +16,7 @@ from apps.utils.queryset import get_child_queryset2, get_child_queryset_u
|
||||||
from apps.utils.serializers import PkSerializer, ComplexSerializer
|
from apps.utils.serializers import PkSerializer, ComplexSerializer
|
||||||
from rest_framework.throttling import UserRateThrottle
|
from rest_framework.throttling import UserRateThrottle
|
||||||
from drf_yasg.utils import swagger_auto_schema
|
from drf_yasg.utils import swagger_auto_schema
|
||||||
|
from drf_yasg import openapi
|
||||||
from apps.utils.decorators import idempotent
|
from apps.utils.decorators import idempotent
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
import json
|
import json
|
||||||
|
@ -200,6 +201,13 @@ class CustomModelViewSet(BulkCreateModelMixin, BulkUpdateModelMixin, ListModelMi
|
||||||
if v not in ALL_PERMS and v != '*':
|
if v not in ALL_PERMS and v != '*':
|
||||||
ALL_PERMS.append(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: {}})
|
@swagger_auto_schema(request_body=ComplexSerializer, responses={200: {}})
|
||||||
@action(methods=['post'], detail=False, perms_map={'post': '*'})
|
@action(methods=['post'], detail=False, perms_map={'post': '*'})
|
||||||
def cquery(self, request):
|
def cquery(self, request):
|
||||||
|
|
Loading…
Reference in New Issue