from django.shortcuts import render

# Create your views here.
from rest_framework import viewsets
from drf_yasg.utils import swagger_auto_schema
from .models import *
from .serializers import *

class CategoryViewSet(viewsets.ModelViewSet):
    queryset = Category.objects.all()
    serializer_class = CategorySerializer
    
    # 应用于整个视图集的动作
    @swagger_auto_schema(tags=['Categories'])
    def get_serializer_class(self):
        return super().get_serializer_class()


class ProductViewSet(viewsets.ModelViewSet):
    queryset = Product.objects.all()
    serializer_class = ProductSerializer

    # 应用于整个视图集的动作
    @swagger_auto_schema(tags=['Products'])
    def get_serializer_class(self):
        return super().get_serializer_class()
