service_edit.py
5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# coding=utf-8
#author: 4N
#createtime: 2021/9/14
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
from app.modules.service.models import Service
from .util.ServiceType import ServiceType
class Api(ApiTemplate):
api_name = "修改服务"
def process(self):
res = {}
try:
guid = self.para.get("guid")
s_type = self.para.get("type")
# 修改本地服务
if s_type in [ServiceType.tile_service.value, ServiceType.map_service.value]:
service = Service.query.filter_by(guid=guid).one_or_none()
if not service:
raise Exception("服务不存在!")
if service.type == ServiceType.map_service.value:
from app.modules.service.map_service.map_service_edit import Api as RealApi
elif service.type == ServiceType.tile_service.value:
from app.modules.service.tile_service.tile_service_edit import Api as RealApi
else:
return res
elif s_type == ServiceType.image_service.value:
from app.modules.service.image_service.image_service_edit import Api as RealApi
else:
return res
api = RealApi()
api.para = self.para
res = api.process()
except Exception as e:
raise Exception("修改服务失败")
return res
api_doc = {
"tags": ["服务接口"],
"parameters": [
{"name": "guid",
"in": "formData",
"type": "string",
"description": "服务guid"},
{"name": "type",
"in": "formData",
"type": "string",
"enum": [st.value for st in ServiceType],
"description": "[矢量地图,电子地图,影像地图]"},
{"name": "url",
"in": "formData",
"type": "string",
"description": "服务地址"},
{"name": "name",
"in": "formData",
"type": "string",
"description": "[矢量地图,电子地图,影像地图]"},
{"name": "title",
"in": "formData",
"type": "string",
"description": "[矢量地图,电子地图,影像地图]"},
{"name": "description",
"in": "formData",
"type": "string",
"description": "[矢量地图,电子地图,影像地图]"},
{"name": "catalog_guid",
"in": "formData",
"type": "string",
"description": "[矢量地图,电子地图,影像地图]"},
{"name": "functions",
"in": "formData",
"type": "string",
"description": "[矢量地图,影像地图]以逗号相隔,可选WMTS,WMS"},
# 影像参数
{"name": "image_guids",
"in": "formData",
"type": "string",
"description": "[影像地图]影像guids,以英文逗号相隔"},
{"name": "scheme",
"in": "formData",
"type": "string",
"description": "切片方案"},
# 切片参数
{"name": "overview",
"in": "formData",
"type": "string",
"description": "[电子地图]缩略图"},
{"name": "scheme_guid",
"in": "formData",
"type": "string",
"description": "电子地图切片方案"},
{"name": "tile_type",
"in": "formData",
"type": "string",
"description": "[电子地图]tile_type"},
{"name": "vendor",
"in": "formData",
"type": "string",
"description": "[电子地图]厂商"},
{"name": "crs",
"in": "formData",
"type": "string",
"description": "[电子地图]坐标系"},
{"name": "datasource",
"in": "formData",
"type": "string",
"description": "[电子地图]数据路径"},
{"name": "layer_name",
"in": "formData",
"type": "string",
"description": "[电子地图]图层名"},
{"name": "layer_alias",
"in": "formData",
"type": "string",
"description": "[电子地图]图层别名"},
{"name": "layer_title",
"in": "formData",
"type": "string",
"description": "[电子地图]图层标题"},
{"name": "layer_style",
"in": "formData",
"type": "string",
"description": "[矢量地图,电子地图]图层样式"},
{"name": "layer_format",
"in": "formData",
"type": "string",
"description": "[电子地图]图层format"},
{"name": "layer_extent",
"in": "formData",
"type": "string",
"description": "[电子地图]图层范围"},
{"name": "layer_description",
"in": "formData",
"type": "string",
"description": "[电子地图]图层描述"},
#矢量地图参数
{"name": "capabilities",
"in": "formData",
"type": "int",
"description": "[矢量地图]"},
{"name": "project",
"in": "formData",
"type": "string",
"description": "[矢量地图]project"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}