MaxKB/apps/setting/views/valid.py
2025-01-13 11:15:51 +08:00

34 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding=utf-8
"""
@project: MaxKB
@Author
@file valid.py
@date2024/7/8 17:50
@desc:
"""
from drf_yasg.utils import swagger_auto_schema
from rest_framework.decorators import action
from rest_framework.request import Request
from rest_framework.views import APIView
from common.auth import TokenAuth, has_permissions
from common.constants.permission_constants import RoleConstants
from common.response import result
from setting.serializers.valid_serializers import ValidSerializer
from setting.swagger_api.valid_api import ValidApi
from django.utils.translation import gettext_lazy as _
class Valid(APIView):
authentication_classes = [TokenAuth]
@action(methods=['GET'], detail=False)
@swagger_auto_schema(operation_summary=_('Get verification results'),
operation_id=_('Get verification results'),
manual_parameters=ValidApi.get_request_params_api(),
responses=result.get_default_response()
, tags=["校验"])
@has_permissions(RoleConstants.ADMIN, RoleConstants.USER)
def get(self, request: Request, valid_type: str, valid_count: int):
return result.success(ValidSerializer(data={'valid_type': valid_type, 'valid_count': valid_count}).valid())