From a2fd3643436c6742da4f8658a8b479446cb066cd Mon Sep 17 00:00:00 2001 From: chenzuoqing Date: Wed, 1 Dec 2021 14:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=B9=E7=9B=AEapp?= =?UTF-8?q?=E7=9A=84=E8=A7=86=E5=9B=BE=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E6=A8=A1=E5=9E=8B=E5=A2=9E=E5=88=A0=E6=9F=A5=E6=94=B9?= =?UTF-8?q?=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/project/routes.py | 4 +-- src/project/views/__init__.py | 0 src/project/{views.py => views/operation.py} | 34 ++---------------- src/project/views/views.py | 36 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 src/project/views/__init__.py rename src/project/{views.py => views/operation.py} (86%) create mode 100644 src/project/views/views.py diff --git a/src/project/routes.py b/src/project/routes.py index 1af8185..a1454ad 100644 --- a/src/project/routes.py +++ b/src/project/routes.py @@ -1,7 +1,7 @@ from flask import Blueprint from flask_restful import Api -from project import views +from project.views import views, operation # 当前app的蓝图,以app名为前缀 @@ -21,4 +21,4 @@ api.add_resource(views.ChannelDetailViews, '/channel//', endpoint="ch api.add_resource(views.ServerViews, '/server/', endpoint="server") api.add_resource(views.ServerDetailView, '/server//', endpoint="server-detail") # 区服信息同步接口,更新区服信息 -api.add_resource(views.ServerSyncView, '/server/sync/', endpoint="server-sync") +api.add_resource(operation.ServerSyncView, '/server/sync/', endpoint="server-sync") diff --git a/src/project/views/__init__.py b/src/project/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/project/views.py b/src/project/views/operation.py similarity index 86% rename from src/project/views.py rename to src/project/views/operation.py index 3103ff3..9a8fc7b 100644 --- a/src/project/views.py +++ b/src/project/views/operation.py @@ -6,42 +6,11 @@ from flask_restful import reqparse from asset.models import Host from project import fields from project.models import Project, Channel, Server, Version -from common.views import ListMixin, CreateMixin, ListCreateViewSet, DetailViewSet +from common.views import CreateMixin from common.permission import token_header_required from common.utils import make_response -class ProjectViews(ListMixin, CreateMixin): - model = Project - paging = False - fields = fields.ProjectFields - - -class ProjectDetailViews(DetailViewSet): - model = Project - fields = fields.ProjectFields - - -class ChannelViews(ListCreateViewSet): - model = Channel - fields = fields.ChannelFields - - -class ChannelDetailViews(DetailViewSet): - model = Channel - fields = fields.ChannelFields - - -class ServerViews(ListCreateViewSet): - model = Server - fields = fields.ServerFields - - -class ServerDetailView(DetailViewSet): - model = Server - fields = fields.ServerFields - - class ServerSyncView(CreateMixin): """同步区服信息,由 `batchQuery` 程序发送采集内容,此视图更新保存""" model = Server @@ -144,3 +113,4 @@ class ServerSyncView(CreateMixin): return make_response(200, 1020, "有区服同步出错", errors=errors) return make_response(200, 1000, "success") + diff --git a/src/project/views/views.py b/src/project/views/views.py new file mode 100644 index 0000000..ea845a8 --- /dev/null +++ b/src/project/views/views.py @@ -0,0 +1,36 @@ +"""数据模型常规增删查改的接口""" + +from project import fields +from project.models import Project, Channel, Server +from common.views import ListMixin, CreateMixin, ListCreateViewSet, DetailViewSet + + +class ProjectViews(ListMixin, CreateMixin): + model = Project + paging = False + fields = fields.ProjectFields + + +class ProjectDetailViews(DetailViewSet): + model = Project + fields = fields.ProjectFields + + +class ChannelViews(ListCreateViewSet): + model = Channel + fields = fields.ChannelFields + + +class ChannelDetailViews(DetailViewSet): + model = Channel + fields = fields.ChannelFields + + +class ServerViews(ListCreateViewSet): + model = Server + fields = fields.ServerFields + + +class ServerDetailView(DetailViewSet): + model = Server + fields = fields.ServerFields