调整项目app的视图目录结构,模型增删查改分开
This commit is contained in:
parent
9f50ff389c
commit
a2fd364343
|
@ -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/<string:pk>/', endpoint="ch
|
|||
api.add_resource(views.ServerViews, '/server/', endpoint="server")
|
||||
api.add_resource(views.ServerDetailView, '/server/<string:pk>/', endpoint="server-detail")
|
||||
# 区服信息同步接口,更新区服信息
|
||||
api.add_resource(views.ServerSyncView, '/server/sync/', endpoint="server-sync")
|
||||
api.add_resource(operation.ServerSyncView, '/server/sync/', endpoint="server-sync")
|
||||
|
|
|
@ -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")
|
||||
|
|
@ -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
|
Loading…
Reference in New Issue