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