Compare commits

...

1 Commits

Author SHA1 Message Date
913071727
0ce7087309 1.不再使用swagger。 2024-09-23 08:44:54 +08:00
5 changed files with 14 additions and 120 deletions

View File

@ -35,22 +35,20 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework_swagger',
'web',
]
# swagger 配置项
# SWAGGER_SETTINGS = {
# # 基础样式
# # 'SECURITY_DEFINITIONS': {
# # "basic": {
# # 'type': 'basic'
# # }
# # },
# 'SECURITY_DEFINITIONS': {
# "basic": {
# 'type': 'basic'
# }
# },
# # 如果需要登录才能够查看接口文档, 登录的链接使用restframework自带的.
# # 'LOGIN_URL': 'rest_framework:login',
# # 'LOGOUT_URL': 'rest_framework:logout',
# 'LOGIN_URL': 'rest_framework:login',
# 'LOGOUT_URL': 'rest_framework:logout',
# # 'DOC_EXPANSION': None,
# # 'SHOW_REQUEST_HEADERS':True,
# # 'USE_SESSION_AUTH': True,
@ -64,11 +62,11 @@ INSTALLED_APPS = [
# 'VALIDATOR_URL': None,
# }
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
]
}
# REST_FRAMEWORK = {
# 'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.IsAuthenticated',
# ]
# }
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',

View File

@ -14,53 +14,13 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.db import router
from django.urls import path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions, routers
from django.contrib import admin
from rest_framework import routers
from django.conf.urls import include
from rest_framework.routers import DefaultRouter
from rest_framework.schemas.views import SchemaView
from tornado.web import url
from web import views
from django.contrib import admin
from django.urls import path
from web.controller.html_parser_controller import HtmlParserController
from web.controller.schedule_controller import SchedulerController
# Swagger documentation setup
# schema_view = get_schema_view(
# openapi.Info(
# title="舆情系统API",
# default_version='v1',
# description="舆情系统API",
# terms_of_service="https://www.google.com/policies/terms/",
# contact=openapi.Contact(email="contact@snippets.local"),
# license=openapi.License(name="BSD License"),
# ),
# public=True,
# permission_classes=(permissions.AllowAny,),
# )
# 重要的是如下三行
from rest_framework.schemas import get_schema_view
from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer
schema_view = get_schema_view(title='Users API', renderer_classes=[OpenAPIRenderer, SwaggerUIRenderer])
router = routers.DefaultRouter()
# router.register('users', views.UserViewSet, base_name='user')
# router.register('groups', views.GroupViewSet, base_name='group')
urlpatterns = [
path('admin/', admin.site.urls),
path('', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path('docs/', schema_view, name='docs'),
path('admin/', admin.site.urls),
path('api/v1/htmlParser/parseHtml', HtmlParserController().parse_html),
path('api/v1/scheduler/create', SchedulerController().create),

View File

@ -1,16 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from collections import namedtuple
from django.http import JsonResponse
from rest_framework.decorators import api_view
from rest_framework.views import APIView
from twisted.protocols.amp import Box
from collector.spiders.collector_spider import CollectorSpider
from web.controller.base_controller import BaseController
from web.dto.api_result import ApiResult
from web.manager.gridgraph_manager import GridGraphManager
from web.manager.log_manager import LogManager
from web.util.dto_util import DtoUtil
from web.vo.parse_html_vo import ParseHtmlVo

View File

@ -1,18 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from rest_framework import serializers
from web.models.training_sensitive_word import TrainingSensitiveWord
# 序列化模型为其他格式
class TrainingSensitiveWordSerializer(serializers.ModelSerializer):
class Meta:
model = TrainingSensitiveWord
# 序列化所有的字段
fields = '__all__'
# 序列化部分字段
# fields = ('id','song','singer','last_modify_date','created')

View File

@ -1,42 +1,2 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from rest_framework import viewsets
from rest_framework.parsers import MultiPartParser, FormParser, JSONParser
from web.models import TrainingSensitiveWord
from web.serializers import TrainingSensitiveWordSerializer
class TrainingSensitiveWordSerializerViewSet(viewsets.ModelViewSet):
"""
CRUD 功能
"""
authentication_classes = []
permission_classes = []
# 解析方式
parser_classes = (MultiPartParser, FormParser, JSONParser)
queryset = TrainingSensitiveWord.objects.all()
serializer_class = TrainingSensitiveWordSerializer
def create(self, request, *args, **kwargs):
"""新建一条音乐"""
pass
def list(self, request, *args, **kwargs):
"""全部音乐数据"""
pass
def retrieve(self, request, *args, **kwargs):
"""查询一条数据"""
pass
def update(self, request, *args, **kwargs):
"""更新一条音乐数据"""
pass
def destroy(self, request, *args, **kwargs):
"""删除一条数据"""
pass